View Bug Activity | Format For Printing
Consider the following code snippet. printf("%g", strtof("0.0", NULL)) printf("%lg", strtod("0.0", NULL)) printf("%llg", strtold("0.0", NULL)) When executed, expecting to see zeroes, the output is: 2.216671e-231 2.216671e-231 2.216671e-231 This seems to be due to strtod_l.c setting int_no is 0 lead_zero = -1 and later dig_no -= lead_zero This increases the number of digits considered for fractional digits since dig_no - int_no is passed to str_to_mpn. This causes the null string terminator to be considered as a digit in the fractional digits.
It would be helpful if you could say on which target that is, because I definitely can't reproduce it, neither on x86_64, nor on ppc32. #define _GNU_SOURCE #include <stdlib.h> #include <stdio.h> int main (void) { printf("%g\n", strtof("0.0", NULL)); printf("%g\n", strtod("0.0", NULL)); printf("%Lg\n", strtold("0.0", NULL)); printf("%g\n", strtof("0", NULL)); printf("%g\n", strtod("0", NULL)); printf("%Lg\n", strtold("0", NULL)); printf("%g\n", strtof("0.000", NULL)); printf("%g\n", strtod("0.000", NULL)); printf("%Lg\n", strtold("0.000", NULL)); printf("%g\n", strtof("0.000e0", NULL)); printf("%g\n", strtod("0.000e0", NULL)); printf("%Lg\n", strtold("0.000e0", NULL)); return 0; } prints just 0s.
Bah, close this due to user error. I neglected to include stdlib.h. Aside: I discovered the problem reading the null terminator while working on the dfp version and assumed it affected the bfp version as well. It looks like str_to_mpn isn't affected by the null so it just works.
Invalid.