This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Fix ynl return value with LDBL_MIN
- From: Marek Polacek <polacek at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Mon, 28 May 2012 15:46:25 +0200
- Subject: [PATCH] Fix ynl return value with LDBL_MIN
ynl (5, LDBL_MIN) should, like yn (5, DBL_MIN) and ynf (5, FLT_MIN),
return -Inf, rather than NaN. This happens in __ieee754_ynl because
GET_LDOUBLE_WORDS sign-extends the sign-exponent (so we get 0xffffffff
instead of 0xffff, thus IIUC the loop cycles longer than it should and
the result is NaN).
I can prepare a test, if wanted.
Regtested on x86_64-linux, ok for trunk if passes testsuite?
2012-05-28 Marek Polacek <polacek@redhat.com>
[BZ #14173]
* sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_ynl): Correct
loop condition.
--- libc/sysdeps/ieee754/ldbl-96/e_jnl.c.mp 2012-05-28 15:22:41.840423694 +0200
+++ libc/sysdeps/ieee754/ldbl-96/e_jnl.c 2012-05-28 15:22:46.321434381 +0200
@@ -360,7 +360,8 @@ __ieee754_ynl (int n, long double x)
b = __ieee754_y1l (x);
/* quit if b is -inf */
GET_LDOUBLE_WORDS (se, i0, i1, b);
- for (i = 1; i < n && se != 0xffff; i++)
+ /* Use 0xffffffff since GET_LDOUBLE_WORDS sign-extends SE. */
+ for (i = 1; i < n && se != 0xffffffff; i++)
{
temp = b;
b = ((long double) (i + i) / x) * b - a;
Marek