diff options
author | Joseph Myers <joseph@codesourcery.com> | 2016-02-19 17:19:53 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2016-02-19 17:19:53 +0000 |
commit | 7b428e744b1ae62c8f26b4e1db487230b796c984 (patch) | |
tree | 7af9532337ac60aa7ffe4005e5271a294aae4758 | |
parent | 59eda029a8a35e5f4e5cd7be0f84c6629e48ec6e (diff) | |
download | glibc-7b428e744b1ae62c8f26b4e1db487230b796c984.tar.gz glibc-7b428e744b1ae62c8f26b4e1db487230b796c984.tar.xz glibc-7b428e744b1ae62c8f26b4e1db487230b796c984.zip |
Fix ldbl-128ibm nextafterl, nexttowardl sign of zero result (bug 19678).
The ldbl-128ibm implementation of nextafterl / nexttowardl returns -0 in FE_DOWNWARD mode when taking the next value below the least positive subnormal, when it should return +0. This patch fixes it to check explicitly for this case. Tested for powerpc. [BZ #19678] * sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c (__nextafterl): Ensure +0.0 is returned when taking the next value below the least positive value.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c | 3 |
2 files changed, 10 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog index bad618941c..5f42093e35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2016-02-19 Joseph Myers <joseph@codesourcery.com> + + [BZ #19678] + * sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c (__nextafterl): + Ensure +0.0 is returned when taking the next value below the least + positive value. + 2016-02-19 Florian Weimer <fweimer@redhat.com> * sysdeps/generic/malloc-machine.h: Assume mutex_init is always diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c b/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c index 515aa1ef5b..0d6469d548 100644 --- a/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c +++ b/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c @@ -87,6 +87,9 @@ long double __nextafterl(long double x, long double y) math_force_eval (u); /* raise underflow flag */ __set_errno (ERANGE); } + /* Avoid returning -0 in FE_DOWNWARD mode. */ + if (x == 0.0L) + return 0.0L; return x; } /* If the high double is an exact power of two and the low |