hadley / r4ds

R for data science: a book
http://r4ds.hadley.nz
Other
4.51k stars 4.19k forks source link

Correct numeric precision comment #1666

Open capnrefsmmat opened 3 months ago

capnrefsmmat commented 3 months ago

It's not correct to say R uses numbers with "a fixed number of decimal places"; that implies fixed-point arithmetic, but R uses floating-point arithmetic, where the number of decimal places depends on the scale of the variable. Numbers near 0 are represented with more decimal places than very large numbers.

It's fair to say the precision is finite, and that's the real problem, as the precision isn't enough to represent the numbers exactly (and can't be, for sqrt(2)).