diff options
author | Joseph Myers <joseph@codesourcery.com> | 2015-02-17 00:41:50 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2015-02-17 00:41:50 +0000 |
commit | ce8fc784e619ada624dc41ed7603211131e66573 (patch) | |
tree | 2e004258c97eb26e6ec382879bcc6f442c2620fa /math/libm-test.inc | |
parent | 0d7036bdb189a1ecb4232101ff83c6dd72439545 (diff) | |
download | glibc-ce8fc784e619ada624dc41ed7603211131e66573.tar.gz glibc-ce8fc784e619ada624dc41ed7603211131e66573.tar.xz glibc-ce8fc784e619ada624dc41ed7603211131e66573.zip |
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.
Diffstat (limited to 'math/libm-test.inc')
-rw-r--r-- | math/libm-test.inc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/math/libm-test.inc b/math/libm-test.inc index 1cf80e3379..85d8b676f7 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -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 / 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 |