This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fix sign of zero on strtod underflow (bug 14519)
- From: Andreas Jaeger <aj at suse dot com>
- To: libc-alpha at sourceware dot org
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Mon, 27 Aug 2012 16:19 +0200
- Subject: Re: Fix sign of zero on strtod underflow (bug 14519)
- References: <Pine.LNX.4.64.1208251547190.12613@digraph.polyomino.org.uk>
On Saturday, August 25, 2012 15:48:29 Joseph S. Myers wrote:
> This patch fixes bug 14519, incorrect sign of zero on certain strtod
> underflow cases (specifically, those where the underflow is detected
> in round_and_return; others already use the "negative ? -0.0 : 0.0"
> construct). The patch is relative to a tree with my previous strtod
> patches <http://sourceware.org/ml/libc-alpha/2012-08/msg00388.html>
> and <http://sourceware.org/ml/libc-alpha/2012-08/msg00548.html>
> (pending review) applied - not so much because of any real dependency
> in the code, but because the testsuite framework added by the bug 3479
> patch (in the most recent version that checks signs of 0) is
> convenient for adding the new tests for this bug. Tested x86_64 and
> x86.
>
> 2012-08-25 Joseph Myers <joseph@codesourcery.com>
>
> [BZ #14519]
> * stdlib/strtod_l.c (round_and_return): Return -0.0 for
> underflowing exponent in case of negative sign.
> * stdlib/tst-strtod-round-data: Add more tests.
> * stdlib/tst-strtod-round.c (tests): Regenerated.
>
> diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c
> index bb18e50..bac2446 100644
> --- a/stdlib/strtod_l.c
> +++ b/stdlib/strtod_l.c
> @@ -183,7 +183,7 @@ round_and_return (mp_limb_t *retval, intmax_t
> exponent, int negative, if (exponent < MIN_EXP - 1 - MANT_DIG)
> {
> __set_errno (ERANGE);
> - return 0.0;
> + return negative ? -0.0 : 0.0;
> }
Thanks, this is fine!
Andreas
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126