recent bug in printf ?
Enache Adrian
enache at rdslink.ro
Sat Apr 19 14:00:30 PDT 2003
$ gcc -x c - && ./a.out
#include <stdio.h>
int main()
{
printf("%.*g\n",8,0.00009);
}
^D
9.0000000e-05
It appears that all others printf implementations will print '9e-05' there.
It's at least what perl expects ( for its Gconvert() macro - and badly
fails a lot of tests because of this ).
The sprintf(3) man page claims:
gG The double argument is converted in style f or e (or F or E for G
conversions). The precision specifies the number of significant
digits. If the precision is missing, 6 digits are given; if the
precision is zero, it is treated as 1. Style e is used if the
exponent from its conversion is less than -4 or greater than or
equal to the precision. Trailing zeros are removed from the
fractional part of the result; a decimal point appears only if it
is followed by at least one digit.
Should I understand that the zeros in 9.0000000e-05 aren't trailing -
because the exponent follows them ?
I use -CURRENT cvsup'ed 4-5 days ago.
Regards
Adi
More information about the freebsd-current
mailing list