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: "bugdal at aerifal dot cx" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: Wed, 02 May 2012 15:22:54 +0000
- Subject: [Bug libc/3479] Incorrect rounding in strtod()
- Auto-submitted: auto-generated
- References: <bug-3479-131@http.sourceware.org/bugzilla/>
http://sourceware.org/bugzilla/show_bug.cgi?id=3479
--- Comment #14 from Rich Felker <bugdal at aerifal dot cx> 2012-05-02 15:22:54 UTC ---
Doing this correctly in the naive way requires some expensive
extended-precision arithmetic. I think one (possibly) less expensive solution
can be found in John Salmon's citation of the recommended practice. If you
compute the result based on DECIMAL_DIG digits in the existing manner, but do
it for BOTH the neighboring values L and U. If the results for L and U are
equal, you're done. If not, you have to determine which of the two D is closer
to (for default rounding mode; other rounding modes are much easier) and this
probably involves converting at least one of them back to decimal, which might
cost you more than just doing the full-precision original calculation...
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.