This is the mail archive of the libc-alpha@sourceware.org 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 atan2l for x near 1


Bug 14610 is the ldbl-128ibm implementation of atan2l treating atan2l
(y, x) as atanl (y) if the high double of x is 1, without checking the
low double.  This causes large ulps for various clog and clog10 tests.
This patch fixes the bug in the obvious way and adds an atan2 test for
it.

Tested x86_64 and x86 (to make sure no new ulps are needed there for
the new test), and powerpc (to confirm the bug is fixed; ulps for clog
and clog10 now look reasonable and there are no new ulps for atan2).

It looks like Andreas's ulps patch
<http://sourceware.org/ml/libc-alpha/2012-10/msg00324.html>, or a
version updated after this patch, still needs to be committed (and
then there are still some other issues he noted that should be
resolved to get clean test results).

2012-10-31  Joseph Myers  <joseph@codesourcery.com>

	[BZ #14610]
	* sysdeps/ieee754/ldbl-128ibm/e_atan2l.c (__ieee754_atan2l): Check
	for low part of x being zero before using __atanl (y).
	* math/libm-test.inc (atan2_test): Add another test.

diff --git a/math/libm-test.inc b/math/libm-test.inc
index 91019a1..9c77392 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -1297,6 +1297,9 @@ atan2_test (void)
   TEST_ff_f (atan2, 1.390625L, 0.9296875L, 0.981498387184244311516296577615519772L);
 
   TEST_ff_f (atan2, -0.00756827042671106339L, -.001792735857538728036L, -1.80338464113663849327153994379639112L);
+#if defined TEST_LDOUBLE && LDBL_MANT_DIG >= 64
+  TEST_ff_f (atan2, 0x1.00000000000001p0L, 0x1.00000000000001p0L, M_PI_4l);
+#endif
 
   END (atan2);
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_atan2l.c b/sysdeps/ieee754/ldbl-128ibm/e_atan2l.c
index fe5c8bd..3e05355 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_atan2l.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_atan2l.c
@@ -65,7 +65,8 @@ __ieee754_atan2l(long double y, long double x)
 	if(((ix)>0x7ff0000000000000LL)||
 	   ((iy)>0x7ff0000000000000LL))	/* x or y is NaN */
 	   return x+y;
-	if(((hx-0x3ff0000000000000LL))==0) return __atanl(y);   /* x=1.0L */
+	if(((hx-0x3ff0000000000000LL))==0
+	   && (lx&0x7fffffffffffffff)==0) return __atanl(y);   /* x=1.0L */
 	m = ((hy>>63)&1)|((hx>>62)&2);	/* 2*sign(x)+sign(y) */
 
     /* when y = 0 */

-- 
Joseph S. Myers
joseph@codesourcery.com


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