]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix ldbl-128ibm nextafterl, nexttowardl sign of zero result (bug 19678).
authorJoseph Myers <joseph@codesourcery.com>
Fri, 19 Feb 2016 17:19:53 +0000 (17:19 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Fri, 19 Feb 2016 17:19:53 +0000 (17:19 +0000)
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.

ChangeLog
sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c

index bad618941c56bb7c26e217696e68a01fed3d244a..5f42093e35aee48ac1cc181879db2fb888739db0 100644 (file)
--- 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
index 515aa1ef5bdd417de4fa6e41022257bacc70f982..0d6469d548f76d07c4cbc79f78ec56259a15681d 100644 (file)
@@ -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