]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix ldbl-128ibm sqrtl (sNaN) (bug 20153).
authorJoseph Myers <joseph@codesourcery.com>
Thu, 26 May 2016 22:58:36 +0000 (22:58 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Thu, 26 May 2016 22:58:36 +0000 (22:58 +0000)
The ldbl-128ibm implementation of sqrtl wrongly returns an sNaN for
signaling NaN arguments.  This patch fixes it to quiet its argument,
using the same x * x + x return for infinities and NaNs as the dbl-64
implementation uses to ensure that +Inf maps to +Inf while -Inf and
NaN map to NaN.

Tested for powerpc.

[BZ #20153]
* sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c (__ieee754_sqrtl): Return
x * x + x for infinities and NaNs.

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

index b597ce964356bf68023820f598d291c7136ddef2..2516304de3916ce11ab0a48e1990aaad2ad40260 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2016-05-26  Joseph Myers  <joseph@codesourcery.com>
 
+       [BZ #20153]
+       * sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c (__ieee754_sqrtl): Return
+       x * x + x for infinities and NaNs.
+
        [BZ #20151]
        * sysdeps/ieee754/ldbl-128/e_j0l.c (__ieee754_j0l): Add NaN
        argument to itself before returning result.
index 96845fe5f896e829927362cdc12b38bc73e59237..51365d6e07662ac2c129ff8ceb746c2fa6924501 100644 (file)
@@ -91,11 +91,9 @@ long double __ieee754_sqrtl(long double x)
     return c.x * i;
   }
   else {
-    if (k>=INT64_C(0x7ff0000000000000)) {
-      if (a.i[0] == INT64_C(0xfff0000000000000))
-       return (big1-big1)/(big-big); /* sqrt (-Inf) = NaN.  */
-      return x; /* sqrt (NaN) = NaN, sqrt (+Inf) = +Inf.  */
-    }
+    if (k>=INT64_C(0x7ff0000000000000))
+      /* sqrt (-Inf) = NaN, sqrt (NaN) = NaN, sqrt (+Inf) = +Inf.  */
+      return x * x + x;
     if (x == 0) return x;
     if (x < 0) return (big1-big1)/(big-big);
     return tm256*__ieee754_sqrtl(x*t512);