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 tanf spurious underflows (bug 18221) [committed]


The flt-32 implementation of tanf produces spurious underflow
exceptions for some small arguments, through computing values on the
order of x^5.  This patch fixes this by adjusting the threshold for
returning x (or, as applicable, +/- 1/x) to 2**-13 (the next term in
the power series being x^3/3).

Tested for x86_64 and x86.  Committed.

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

2015-05-15  Joseph Myers  <joseph@codesourcery.com>

	[BZ #18221]
	* sysdeps/ieee754/flt-32/k_tanf.c (__kernel_tanf): Use 2**-13 not
	2**-28 as threshold for returning x or +/- 1/x.
	* math/auto-libm-test-in: Add more tests of tan.
	* math/auto-libm-test-out: Regenerated.

diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in
index 2a88403..e483569 100644
--- a/math/auto-libm-test-in
+++ b/math/auto-libm-test-in
@@ -2418,6 +2418,8 @@ tan pi/4
 tan 0.75
 tan 0x1p65
 tan -0x1p65
+tan 0x1p-27
+tan -0x1p-27
 tan 0xc.9p-4
 tan 0xc.908p-4
 tan 0xc.90cp-4
diff --git a/sysdeps/ieee754/flt-32/k_tanf.c b/sysdeps/ieee754/flt-32/k_tanf.c
index d918826..a67f36e 100644
--- a/sysdeps/ieee754/flt-32/k_tanf.c
+++ b/sysdeps/ieee754/flt-32/k_tanf.c
@@ -45,7 +45,7 @@ float __kernel_tanf(float x, float y, int iy)
 	int32_t ix,hx;
 	GET_FLOAT_WORD(hx,x);
 	ix = hx&0x7fffffff;	/* high word of |x| */
-	if(ix<0x31800000)			/* x < 2**-28 */
+	if(ix<0x39000000)			/* x < 2**-13 */
 	    {if((int)x==0) {			/* generate inexact */
 		if((ix|(iy+1))==0) return one/fabsf(x);
 		else return (iy==1)? x: -one/x;

-- 
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]