[Rd] R 2.5.0 refuses to print enough digits to recover exact floating point values

Petr Savicky savicky at cs.cas.cz
Wed May 23 19:22:47 CEST 2007


This is an addition to my previous message.

16 digits are indeed not sufficient to represent a double
value exactly. The next table is calculated in bc calculator.
It shows that if we restrict (or round) double values
to 16 decadic digits then from 4 to 5 consecutive distinct
double values get the same 16 digit decadic code.

1.234567890123456  a 16-digit number for comparison
1.0000000000000000000000000000     1 + 0*2^(-52)
1.0000000000000002220446049250     1 + 1*2^(-52)
1.0000000000000004440892098500     1 + 2*2^(-52)
1.0000000000000006661338147750     1 + 3*2^(-52)
1.0000000000000008881784197001     1 + 4*2^(-52)
1.0000000000000011102230246251     1 + 5*2^(-52)
1.0000000000000013322676295501     1 + 6*2^(-52)
1.0000000000000015543122344752     1 + 7*2^(-52)
1.0000000000000017763568394002     1 + 8*2^(-52)
1.0000000000000019984014443252     1 + 9*2^(-52)
1.0000000000000022204460492503     1 + 10*2^(-52)
1.0000000000000024424906541753     1 + 11*2^(-52)
1.0000000000000026645352591003     1 + 12*2^(-52)
1.0000000000000028865798640254     1 + 13*2^(-52)
1.0000000000000031086244689504     1 + 14*2^(-52)
1.0000000000000033306690738754     1 + 15*2^(-52)
1.0000000000000035527136788005     1 + 16*2^(-52)
1.0000000000000037747582837255     1 + 17*2^(-52)
1.0000000000000039968028886505     1 + 18*2^(-52)
1.0000000000000042188474935755     1 + 19*2^(-52)

Petr.



More information about the R-devel mailing list