Fix sign of zero on strtod underflow (bug 14519).

This commit is contained in:
Joseph Myers 2012-08-27 16:04:19 +00:00
parent af92131a8e
commit 7efb4737dd
5 changed files with 117 additions and 2 deletions

View File

@ -1,5 +1,11 @@
2012-08-27 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.
[BZ #3479]
* stdlib/strtod_l.c (NDIG): Remove.
(HEXNDIG): Likewise.

3
NEWS
View File

@ -11,7 +11,8 @@ Version 2.17
3479, 6778, 6808, 9685, 11607, 13717, 13696, 13939, 14042, 14090, 14166,
14150, 14151, 14154, 14157, 14166, 14173, 14195, 14252, 14283, 14298,
14303, 14307, 14328, 14331, 14336, 14337, 14347, 14349, 14459, 14505
14303, 14307, 14328, 14331, 14336, 14337, 14347, 14349, 14459, 14505,
14519
* Support for STT_GNU_IFUNC symbols added for s390 and s390x.
Optimized versions of memcpy, memset, and memcmp added for System z10 and

View File

@ -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;
}
mp_size_t shift = MIN_EXP - 1 - exponent;

File diff suppressed because one or more lines are too long

View File

@ -6255,6 +6255,110 @@ static const struct test tests[] = {
-0xcp-16448L,
-0xcp-16448L,
-0xcp-16448L),
TEST ("-0x0.7p-149",
-0x8p-152f,
-0x0p+0f,
-0x0p+0f,
-0x0p+0f,
-0x3.8p-152,
-0x3.8p-152,
-0x3.8p-152,
-0x3.8p-152,
-0x3.8p-152L,
-0x3.8p-152L,
-0x3.8p-152L,
-0x3.8p-152L,
-0x3.8p-152L,
-0x3.8p-152L,
-0x3.8p-152L,
-0x3.8p-152L,
true,
-0x3.8p-152L,
-0x3.8p-152L,
-0x3.8p-152L,
-0x3.8p-152L,
-0x3.8p-152L,
-0x3.8p-152L,
-0x3.8p-152L,
-0x3.8p-152L),
TEST ("-0x0.7p-1074",
-0x8p-152f,
-0x0p+0f,
-0x0p+0f,
-0x0p+0f,
-0x4p-1076,
-0x0p+0,
-0x0p+0,
-0x0p+0,
-0x4p-1076L,
-0x0p+0L,
-0x0p+0L,
-0x0p+0L,
-0x1.cp-1076L,
-0x1.cp-1076L,
-0x1.cp-1076L,
-0x1.cp-1076L,
false,
-0x4p-1076L,
-0x0p+0L,
-0x0p+0L,
-0x0p+0L,
-0x1.cp-1076L,
-0x1.cp-1076L,
-0x1.cp-1076L,
-0x1.cp-1076L),
TEST ("-0x0.7p-16445",
-0x8p-152f,
-0x0p+0f,
-0x0p+0f,
-0x0p+0f,
-0x4p-1076,
-0x0p+0,
-0x0p+0,
-0x0p+0,
-0x4p-1076L,
-0x0p+0L,
-0x0p+0L,
-0x0p+0L,
-0x8p-16448L,
-0x0p+0L,
-0x0p+0L,
-0x0p+0L,
false,
-0x4p-1076L,
-0x0p+0L,
-0x0p+0L,
-0x0p+0L,
-0x3.8p-16448L,
-0x3.8p-16448L,
-0x3.8p-16448L,
-0x3.8p-16448L),
TEST ("-0x0.7p-16494",
-0x8p-152f,
-0x0p+0f,
-0x0p+0f,
-0x0p+0f,
-0x4p-1076,
-0x0p+0,
-0x0p+0,
-0x0p+0,
-0x4p-1076L,
-0x0p+0L,
-0x0p+0L,
-0x0p+0L,
-0x8p-16448L,
-0x0p+0L,
-0x0p+0L,
-0x0p+0L,
false,
-0x4p-1076L,
-0x0p+0L,
-0x0p+0L,
-0x0p+0L,
-0x4p-16496L,
-0x0p+0L,
-0x0p+0L,
-0x0p+0L),
};
static int