------- Comment #6 from neil at gcc dot gnu dot org 2007-10-18 15:24 ------- (In reply to comment #5)
> I believe more than 160 bits are required to get even single-precision numbers > right with DECIMAL_DIG digits precision and an exponent. I'm going to try and > prove this by finding an example. It could be hard as I believe 160 is only > just below the required number. Here's an example to prove this assertion. When compiled with GCC 4.1.2 or 4.1.3 with -std=c99, assuming a correctly-rounding libc (e.g. NetBSD's; glibc also seems to get this correct) you get the following output: 0x1.8p-147 0x1.4p-147 8.40779078594890243e-45 So not only is it rounded incorrectly, but the number it is rounded to, when converted back to decimal, does not even match the input number in the first digit. #include <stdio.h> #include <stdlib.h> int main (void) { float f1 = 7.7071415537864938e-45; float f2 = strtof ("7.7071415537864938e-45", NULL); printf( "%a %a %0.18g\n", f1, f2, f1); return 0; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21718