This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix ldbl-128ibm logl inaccuracy near 1 (bug 19351) [committed]

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.  Committed.

2015-12-09  Joseph Myers  <>

	[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.

diff --git a/sysdeps/ieee754/ldbl-128ibm/e_logl.c b/sysdeps/ieee754/ldbl-128ibm/e_logl.c
index dcac380..14acfc2 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_logl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_logl.c
@@ -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;

Joseph S. Myers

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]