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-128/ldbl-128ibm acosl inaccuracy (bug 18038, bug 18039) [committed]

The ldbl-128 and ldbl-128ibm implementations of acosl have similar
bugs, using a threshold of 0x1p-57L to determine when they just return
pi/2.  Since the result pi/2 - asinl (x) is roughly pi/2 - x for small
x, the relevant cut-off is actually x being < 0.5ulp of 1.  This patch
fixes the implementations to use that cut-off and adds tests of small
acos arguments.

Tested for powerpc and mips64.  Also tested for x86_64 and x86; no
ulps updates needed.  Committed.

(auto-libm-test-out diffs omitted below.)

2015-02-26  Joseph Myers  <>

	[BZ #18038]
	[BZ #18039]
	* sysdeps/ieee754/ldbl-128/e_acosl.c (__ieee754_acosl): Only
	return pi/2 for arguments below 0x1p-113L.
	* sysdeps/ieee754/ldbl-128ibm/e_acosl.c (__ieee754_acosl): Only
	return pi/2 for arguments below 0x1p-106L.
	* math/auto-libm-test-in: Add more tests of acos.
	* math/auto-libm-test-out: Regenerated.

diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in
index bd85805..19d5396 100644
--- a/math/auto-libm-test-in
+++ b/math/auto-libm-test-in
@@ -33,6 +33,37 @@ acos 0x0.ffffffffffffp0
 acos -0x0.ffffffffffffp0
 acos 0x0.ffffffffffffffffp0
 acos -0x0.ffffffffffffffffp0
+acos 0x1p-5
+acos 0x1p-10
+acos 0x1p-15
+acos 0x1p-20
+acos 0x1p-25
+acos 0x1p-30
+acos 0x1p-35
+acos 0x1p-40
+acos 0x1p-45
+acos 0x1p-50
+acos 0x1p-55
+acos 0x1p-60
+acos 0x1p-65
+acos 0x1p-70
+acos 0x1p-75
+acos 0x1p-80
+acos 0x1p-85
+acos 0x1p-90
+acos 0x1p-95
+acos 0x1p-100
+acos 0x1p-105
+acos 0x1p-110
+acos 0x1p-115
+acos 0x1p-120
+acos -0x1p-5
+acos -0x1p-25
+acos -0x1p-45
+acos -0x1p-65
+acos -0x1p-85
+acos -0x1p-105
+acos -0x1p-125
 acos min
 acos -min
 acos min_subnorm
diff --git a/sysdeps/ieee754/ldbl-128/e_acosl.c b/sysdeps/ieee754/ldbl-128/e_acosl.c
index 28c94ed..8c8ec93 100644
--- a/sysdeps/ieee754/ldbl-128/e_acosl.c
+++ b/sysdeps/ieee754/ldbl-128/e_acosl.c
@@ -173,7 +173,7 @@ __ieee754_acosl (long double x)
   else if (ix < 0x3ffe0000)	/* |x| < 0.5 */
-      if (ix < 0x3fc60000)	/* |x| < 2**-57 */
+      if (ix < 0x3f8e0000)	/* |x| < 2**-113 */
 	return pio2_hi + pio2_lo;
       if (ix < 0x3ffde000)	/* |x| < .4375 */
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_acosl.c b/sysdeps/ieee754/ldbl-128ibm/e_acosl.c
index 2cb2882..e5030f1 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_acosl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_acosl.c
@@ -169,7 +169,7 @@ __ieee754_acosl (long double x)
   if (a < 0.5L)
-      if (a < 6.938893903907228e-18L)	/* |x| < 2**-57 */
+      if (a < 0x1p-106L)
 	return pio2_hi + pio2_lo;
       if (a < 0.4375L)

Joseph S. Myers

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