R FAQ 7.31
is probably the most famous FAQ, so it deserves its own
0.3 + 0.6 == 0.9
#> [1] FALSE
sqrt(2)^2 == 2
#> [1] FALSE
This wikipedia article is a good introduction to the Double-precision floating-point format, but in short double
(what we call numeric
in R) are encoded in 64 bits:
- the first bit is the sign bit
- the 11 following bits are the exponent
- the remaining 52 bits are the fraction
Installation
From github:
devtools::install_github( "ThinkR-open/seven31" )
Reveal the bits
reveal
Compare two numbers
compare
shows the differences. On