Bugzilla will be upgraded to version 5.0 on December 2, 2018. The outage period for the upgrade will start at 0:00 UTC and have a duration of 12 hours
Bug 801 - *printf with precision >= 16 gives bogus additional digits
*printf with precision >= 16 gives bogus additional digits
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Cristian Gafton
Depends On:
  Show dependency treegraph
Reported: 1999-01-12 13:21 EST by Christoph Rohland
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 1999-01-18 17:04:34 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Christoph Rohland 1999-01-12 13:21:26 EST
#include <stdio.h>

    int i;
    for (i=10; i< 20 ;i++)
        printf ("%d: %.*e\n",i,i,12.3456789);


10: 1.2345678900e+01
11: 1.23456789000e+01
12: 1.234567890000e+01
13: 1.2345678900000e+01
14: 1.23456789000000e+01
15: 1.234567890000000e+01
16: 1.2345678899999999e+01
17: 1.23456788999999993e+01
18: 1.234567889999999935e+01
19: 1.2345678899999999345e+01
Comment 1 David Lawrence 1999-01-12 14:27:59 EST
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
a developer.
Comment 2 Cristian Gafton 1999-01-14 02:00:59 EST
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
Comment 3 Anonymous 1999-01-14 02:57:59 EST
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.
Comment 4 Cristian Gafton 1999-01-18 17:04:59 EST
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.
Comment 5 Anonymous 1999-01-19 04:32:59 EST
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'

Note You need to log in before you can comment on or make changes to this bug.