Red Hat Bugzilla – Bug 801
*printf with precision >= 16 gives bogus additional digits
Last modified: 2008-05-01 11:37:48 EDT
for (i=10; i< 20 ;i++)
printf ("%d: %.*e\n",i,i,12.3456789);
I have verified this to be true. I compiled and ran the sample of code
on a test lab machine and got the same results. It will be assigned to
The double number are guaranteed up to 15 precission digits. After
that pretty much nothing is guaranteed or specialized math libs have
to be used.
This is what pretty much standards require off the double precission
That's only have of the truth...
I do not want to have more digits, but if I give a precision > 16 it
should fill up with zeros and not print some other bogus numbers.
One can not blame libm for trying to approximate to its best a double
number out of range. The standards define the behavior as
"unspecified" in this case, so what it happens is perfectly within the
limits of the standards.
O.K. I will state at last, that I am not confident with the answer but
do not want to hassle any more.
Porting to RedHat Linux makes this more difficult. Also I could not
find the stated standards restriction in 'ISO/IEC 9899 : 1990
Programming Languages - C'