This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/3479] Incorrect rounding in strtod()
- From: "john at thesalmons dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 5 Feb 2007 21:54:35 -0000
- Subject: [Bug libc/3479] Incorrect rounding in strtod()
- References: <20061107172025.3479.hack@watson.ibm.com>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From john at thesalmons dot org 2007-02-05 21:54 -------
I was not sufficiently clear in Comment #2.
The fact that the code prints FAIL in certain cases does not demonstrate whether
gcc's literal parser or glibc's strtof is faulty. It only proves that (at
least) one of them is failing to adhere to "Recommended Practice" which says
they should be the same.
HOWEVER, careful inspection of the output, as well as knowledge of how the
particular test case was chosen makes it pretty clear that *for this case* gcc
is doing the right thing and strtof is at fault. gcc's rounding may not be
perfect, but that's not at issue here.
The input, "1.00000005960464477550" is the result of printf("%.21g", x)
where x = 1 + FLT_EPSILON/2 + LDBL_EPSILON. I.e., it is specifically
constructed to be *just a little bit larger* than the mid-point between two
representable floats. Correct rounding should be to the larger of the two
nearby floats, i.e., 1+FLT_EPSILON. gcc correctly constructs the literal
0x1.00002p0. strof incorrectly returns the value 1.0p0.
--
http://sourceware.org/bugzilla/show_bug.cgi?id=3479
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.