This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Fix ldbl-128ibm nextafterl, nexttowardl sign of zero result (bug 19678) [committed]
- From: Joseph Myers <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Fri, 19 Feb 2016 17:20:55 +0000
- Subject: Fix ldbl-128ibm nextafterl, nexttowardl sign of zero result (bug 19678) [committed]
- Authentication-results: sourceware.org; auth=none
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. Committed.
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.
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c b/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c
index 515aa1e..0d6469d 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
--
Joseph S. Myers
joseph@codesourcery.com