]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix ldbl-128ibm logl inaccuracy near 1 (bug 19351).
authorJoseph Myers <joseph@codesourcery.com>
Wed, 9 Dec 2015 23:51:11 +0000 (23:51 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 9 Dec 2015 23:51:11 +0000 (23:51 +0000)
The ldbl-128ibm implementation of logl is inaccurate for arguments
near 1, because when deciding whether to bypass a series expansion for
log(1+z), where z = x-1, it compares the square of z rather than z
itself with an epsilon value.  This patch fixes that comparison, so
eliminating the test failures for inaccuracy of logl in such cases.

Tested for powerpc.

[BZ #19351]
* sysdeps/ieee754/ldbl-128ibm/e_logl.c (__ieee754_logl): When
expanding log(1+z), compare z rather than its square with epsilon
to determine when to avoid evaluating the expansion.

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

index 1c7b198d5414f048163a57936e20f723a0f5f2ae..ec8807cfac1491c1316ce4ea94a8249947dc353f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2015-12-09  Joseph Myers  <joseph@codesourcery.com>
 
+       [BZ #19351]
+       * sysdeps/ieee754/ldbl-128ibm/e_logl.c (__ieee754_logl): When
+       expanding log(1+z), compare z rather than its square with epsilon
+       to determine when to avoid evaluating the expansion.
+
        [BZ #19350]
        * sysdeps/ieee754/ldbl-128ibm/e_sinhl.c (__ieee754_sinhl):
        Increase overflow threshold.
index dcac38062c67f76e1b43dc10a4a5ee273278c274..14acfc2db7a960db8211145465cf5a871610af5d 100644 (file)
@@ -270,7 +270,7 @@ __ieee754_logl(long double x)
   /* Series expansion of log(1+z).  */
   w = z * z;
   /* Avoid spurious underflows.  */
-  if (__glibc_unlikely(w <= ldbl_epsilon))
+  if (__glibc_unlikely (fabsl (z) <= ldbl_epsilon))
     y = 0.0L;
   else
     {