mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-07 06:43:00 +03:00
Fix sign of remquo zero remainder in round-downward mode (bug 17987).
Various remquo implementations produce a zero remainder with the wrong sign (a zero remainder should always have the sign of the first argument, as specified in IEEE 754) in round-downward mode, resulting from the sign of 0 - 0. This patch checks for zero results and fixes their sign accordingly. Tested for x86_64, x86, mips64 and powerpc. [BZ #17987] * sysdeps/ieee754/dbl-64/s_remquo.c (__remquo): Ensure sign of zero result does not depend on the sign resulting from subtraction. * sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c (__remquo): Likewise. * sysdeps/ieee754/flt-32/s_remquof.c (__remquof): Likewise. * sysdeps/ieee754/ldbl-128/s_remquol.c (__remquol): Likewise. * sysdeps/ieee754/ldbl-128ibm/s_remquol.c (__remquol): Likewise. * sysdeps/ieee754/ldbl-96/s_remquol.c (__remquol): Likewise. * math/libm-test.inc (remquo_test_data): Add more tests.
This commit is contained in:
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
|||||||
|
2015-02-16 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
[BZ #17987]
|
||||||
|
* sysdeps/ieee754/dbl-64/s_remquo.c (__remquo): Ensure sign of
|
||||||
|
zero result does not depend on the sign resulting from
|
||||||
|
subtraction.
|
||||||
|
* sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c (__remquo):
|
||||||
|
Likewise.
|
||||||
|
* sysdeps/ieee754/flt-32/s_remquof.c (__remquof): Likewise.
|
||||||
|
* sysdeps/ieee754/ldbl-128/s_remquol.c (__remquol): Likewise.
|
||||||
|
* sysdeps/ieee754/ldbl-128ibm/s_remquol.c (__remquol): Likewise.
|
||||||
|
* sysdeps/ieee754/ldbl-96/s_remquol.c (__remquol): Likewise.
|
||||||
|
* math/libm-test.inc (remquo_test_data): Add more tests.
|
||||||
|
|
||||||
2015-02-16 Paul Eggert <eggert@cs.ucla.edu>
|
2015-02-16 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
* manual/time.texi (TZ Variable): glibc no longer comes with tzdata.
|
* manual/time.texi (TZ Variable): glibc no longer comes with tzdata.
|
||||||
|
2
NEWS
2
NEWS
@@ -10,7 +10,7 @@ Version 2.22
|
|||||||
* The following bugs are resolved with this release:
|
* The following bugs are resolved with this release:
|
||||||
|
|
||||||
4719, 15467, 15790, 16560, 17569, 17792, 17912, 17932, 17944, 17949,
|
4719, 15467, 15790, 16560, 17569, 17792, 17912, 17932, 17944, 17949,
|
||||||
17964, 17965, 17967, 17969, 17978.
|
17964, 17965, 17967, 17969, 17978, 17987.
|
||||||
|
|
||||||
Version 2.21
|
Version 2.21
|
||||||
|
|
||||||
|
@@ -8818,6 +8818,16 @@ static const struct test_ffI_f1_data remquo_test_data[] =
|
|||||||
TEST_ffI_f1 (remquo, -1, -max_value / 4, -1, 0, NO_INEXACT_EXCEPTION),
|
TEST_ffI_f1 (remquo, -1, -max_value / 4, -1, 0, NO_INEXACT_EXCEPTION),
|
||||||
TEST_ffI_f1 (remquo, -1, max_value / 8, -1, 0, NO_INEXACT_EXCEPTION),
|
TEST_ffI_f1 (remquo, -1, max_value / 8, -1, 0, NO_INEXACT_EXCEPTION),
|
||||||
TEST_ffI_f1 (remquo, -1, -max_value / 8, -1, 0, NO_INEXACT_EXCEPTION),
|
TEST_ffI_f1 (remquo, -1, -max_value / 8, -1, 0, NO_INEXACT_EXCEPTION),
|
||||||
|
|
||||||
|
TEST_ffI_f1 (remquo, max_value, max_value / 2, plus_zero, 2, NO_INEXACT_EXCEPTION),
|
||||||
|
TEST_ffI_f1 (remquo, max_value, -max_value / 2, plus_zero, -2, NO_INEXACT_EXCEPTION),
|
||||||
|
TEST_ffI_f1 (remquo, -max_value, max_value / 2, minus_zero, -2, NO_INEXACT_EXCEPTION),
|
||||||
|
TEST_ffI_f1 (remquo, -max_value, -max_value / 2, minus_zero, 2, NO_INEXACT_EXCEPTION),
|
||||||
|
|
||||||
|
TEST_ffI_f1 (remquo, 2, 1, plus_zero, 2, NO_INEXACT_EXCEPTION),
|
||||||
|
TEST_ffI_f1 (remquo, 2, -1, plus_zero, -2, NO_INEXACT_EXCEPTION),
|
||||||
|
TEST_ffI_f1 (remquo, -2, 1, minus_zero, -2, NO_INEXACT_EXCEPTION),
|
||||||
|
TEST_ffI_f1 (remquo, -2, -1, minus_zero, 2, NO_INEXACT_EXCEPTION),
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -101,6 +101,9 @@ __remquo (double x, double y, int *quo)
|
|||||||
|
|
||||||
*quo = qs ? -cquo : cquo;
|
*quo = qs ? -cquo : cquo;
|
||||||
|
|
||||||
|
/* Ensure correct sign of zero result in round-downward mode. */
|
||||||
|
if (x == 0.0)
|
||||||
|
x = 0.0;
|
||||||
if (sx)
|
if (sx)
|
||||||
x = -x;
|
x = -x;
|
||||||
return x;
|
return x;
|
||||||
|
@@ -100,6 +100,9 @@ __remquo (double x, double y, int *quo)
|
|||||||
|
|
||||||
*quo = qs ? -cquo : cquo;
|
*quo = qs ? -cquo : cquo;
|
||||||
|
|
||||||
|
/* Ensure correct sign of zero result in round-downward mode. */
|
||||||
|
if (x == 0.0)
|
||||||
|
x = 0.0;
|
||||||
if (sx)
|
if (sx)
|
||||||
x = -x;
|
x = -x;
|
||||||
return x;
|
return x;
|
||||||
|
@@ -100,6 +100,9 @@ __remquof (float x, float y, int *quo)
|
|||||||
|
|
||||||
*quo = qs ? -cquo : cquo;
|
*quo = qs ? -cquo : cquo;
|
||||||
|
|
||||||
|
/* Ensure correct sign of zero result in round-downward mode. */
|
||||||
|
if (x == 0.0f)
|
||||||
|
x = 0.0f;
|
||||||
if (sx)
|
if (sx)
|
||||||
x = -x;
|
x = -x;
|
||||||
return x;
|
return x;
|
||||||
|
@@ -102,6 +102,9 @@ __remquol (long double x, long double y, int *quo)
|
|||||||
|
|
||||||
*quo = qs ? -cquo : cquo;
|
*quo = qs ? -cquo : cquo;
|
||||||
|
|
||||||
|
/* Ensure correct sign of zero result in round-downward mode. */
|
||||||
|
if (x == 0.0L)
|
||||||
|
x = 0.0L;
|
||||||
if (sx)
|
if (sx)
|
||||||
x = -x;
|
x = -x;
|
||||||
return x;
|
return x;
|
||||||
|
@@ -107,6 +107,9 @@ __remquol (long double x, long double y, int *quo)
|
|||||||
|
|
||||||
*quo = qs ? -cquo : cquo;
|
*quo = qs ? -cquo : cquo;
|
||||||
|
|
||||||
|
/* Ensure correct sign of zero result in round-downward mode. */
|
||||||
|
if (x == 0.0L)
|
||||||
|
x = 0.0L;
|
||||||
if (sx)
|
if (sx)
|
||||||
x = -x;
|
x = -x;
|
||||||
return x;
|
return x;
|
||||||
|
@@ -101,6 +101,9 @@ __remquol (long double x, long double p, int *quo)
|
|||||||
|
|
||||||
*quo = qs ? -cquo : cquo;
|
*quo = qs ? -cquo : cquo;
|
||||||
|
|
||||||
|
/* Ensure correct sign of zero result in round-downward mode. */
|
||||||
|
if (x == 0.0L)
|
||||||
|
x = 0.0L;
|
||||||
if (sx)
|
if (sx)
|
||||||
x = -x;
|
x = -x;
|
||||||
return x;
|
return x;
|
||||||
|
Reference in New Issue
Block a user