Skip to content
Prev 60880 / 63421 Next

Floating point issue

The following function, 'bitC' from ?numToBits, displays the bits in a
double precision number, separated into the sign bit, the 11 exponent bits,
and the 52 bits in the mantissa.  I've shown the results with your numbers
from R-2.4.0 on my Windows 11 Lenovo laptop: what do you get?
one double
+     b <- substr(as.character(rev(numToBits(x))), 2L, 2L)
+     paste0(c(b[1L], " ", b[2:12], " | ", b[13:64]), collapse = "")
+   }, ""))
# [1] 0 10001010010 | 0000100010110010101000101100001010000000001010010001
# [1] 0 10001010010 | 0000100010110010101000101100001010000000001010010001
# [1] 0 00000000000 | 0000000000000000000000000000000000000000000000000000
# [1] 0 10001010010 | 0000100010110010101000101100001010000000001010010001

-Bill

On Sun, Jul 10, 2022 at 7:00 AM Antoine Fabri <antoine.fabri at gmail.com>
wrote: