in reply to Re^5: RFC: Large Floating Point Numbers - Rounding Errors
in thread RFC: Large Floating Point Numbers - Rounding Errors
Try the following C program and see how the periodic part of the base 2 representation of those rational numbers is truncated and how it converts back to base 10:
On my amd64 linux box it outputs:#include <stdio.h> double n[] = { 0.000005, 0.000015, 0.000025, 0.000035, 0.000045, 0.000 +055, 0.000065 }; int main(int argc, char *argv[]) { int i; for (i = 0; i < sizeof(n)/sizeof(*n); i++) { printf("%40.30a => %40.30f\n", n[i], n[i]); } return 0; }
0x1.4f8b588e368f100000000000000000p-18 => 0.0000050000000000 +00000409015270 0x1.f75104d551d6900000000000000000p-17 => 0.0000150000000000 +00000380012861 0x1.a36e2eb1c432d00000000000000000p-16 => 0.0000250000000000 +00001198043401 0x1.2599ed7c6fbd200000000000000000p-15 => 0.0000349999999999 +99996933876256 0x1.797cc39ffd60f00000000000000000p-15 => 0.0000450000000000 +00002834104479 0x1.cd5f99c38b04b00000000000000000p-15 => 0.0000550000000000 +00001958069124 0x1.10a137f38c54300000000000000000p-14 => 0.0000649999999999 +99994305770190
|
|---|