This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: glibc conditioning
- To: Jinsong Zhao <zhaojs at cadence dot com>
- Subject: Re: glibc conditioning
- From: Ulrich Drepper <drepper at redhat dot com>
- Date: 27 Aug 2001 14:51:56 -0700
- Cc: libc-alpha at sources dot redhat dot com, stevew at srware dot com
- References: <200108272128.OAA09445@aton.Cadence.COM>
- Reply-To: drepper at cygnus dot com (Ulrich Drepper)
glibc is 100% correct. Any implementation which produces a different
result deliberately returns a wrong result from strtod(). ISO C
doesn't require the result to be correct so those implementors
unfortunately cannot be held responsible but it does not make the
result correct. Do the math.
Whoever writes code which assumes something different cannot be
trusted and people who use this software should be aware of this. And
obviously the author of the test program in the "document" referenced
cannot even write code seven lines of code without a bug since I
guarantee you the program fails everywhere. Who would listen to
somebody like that?
If you rely on rounding use the appropriate function. Use round()
instead of a cast to int. The latter is required to truncate, the
former, as the name suggests, rounds. And yes, round() is a standard
function.
--
---------------. ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Red Hat `--' drepper at redhat.com `------------------------