]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/ieee754/flt-32/k_tanf.c
1 /* k_tanf.c -- float version of k_tan.c
5 * ====================================================
6 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8 * Developed at SunPro, a Sun Microsystems, Inc. business.
9 * Permission to use, copy, modify, and distribute this
10 * software is freely granted, provided that this notice
12 * ====================================================
15 #if defined(LIBM_SCCS) && !defined(lint)
16 static char rcsid
[] = "$NetBSD: k_tanf.c,v 1.4 1995/05/10 20:46:39 jtc Exp $";
21 #include <math_private.h>
22 #include <math-underflow.h>
24 one
= 1.0000000000e+00, /* 0x3f800000 */
25 pio4
= 7.8539812565e-01, /* 0x3f490fda */
26 pio4lo
= 3.7748947079e-08, /* 0x33222168 */
28 3.3333334327e-01, /* 0x3eaaaaab */
29 1.3333334029e-01, /* 0x3e088889 */
30 5.3968254477e-02, /* 0x3d5d0dd1 */
31 2.1869488060e-02, /* 0x3cb327a4 */
32 8.8632395491e-03, /* 0x3c11371f */
33 3.5920790397e-03, /* 0x3b6b6916 */
34 1.4562094584e-03, /* 0x3abede48 */
35 5.8804126456e-04, /* 0x3a1a26c8 */
36 2.4646313977e-04, /* 0x398137b9 */
37 7.8179444245e-05, /* 0x38a3f445 */
38 7.1407252108e-05, /* 0x3895c07a */
39 -1.8558637748e-05, /* 0xb79bae5f */
40 2.5907305826e-05, /* 0x37d95384 */
43 float __kernel_tanf(float x
, float y
, int iy
)
48 ix
= hx
&0x7fffffff; /* high word of |x| */
49 if(ix
<0x39000000) /* x < 2**-13 */
50 {if((int)x
==0) { /* generate inexact */
51 if((ix
|(iy
+1))==0) return one
/fabsf(x
);
54 math_check_force_underflow (x
);
61 if(ix
>=0x3f2ca140) { /* |x|>=0.6744 */
62 if(hx
<0) {x
= -x
; y
= -y
;}
66 if (fabsf (x
) < 0x1p
-13f
)
67 return (1 - ((hx
>> 30) & 2)) * iy
* (1.0f
- 2 * iy
* x
);
71 /* Break x^5*(T[1]+x^2*T[2]+...) into
72 * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) +
73 * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12]))
75 r
= T
[1]+w
*(T
[3]+w
*(T
[5]+w
*(T
[7]+w
*(T
[9]+w
*T
[11]))));
76 v
= z
*(T
[2]+w
*(T
[4]+w
*(T
[6]+w
*(T
[8]+w
*(T
[10]+w
*T
[12])))));
78 r
= y
+ z
*(s
*(r
+v
)+y
);
83 return (float)(1-((hx
>>30)&2))*(v
-(float)2.0*(x
-(w
*w
/(w
+v
)-r
)));
86 else { /* if allow error up to 2 ulp,
87 simply return -1.0/(x+r) here */
88 /* compute -1.0/(x+r) accurately */
93 SET_FLOAT_WORD(z
,i
&0xfffff000);
94 v
= r
-(z
- x
); /* z+v = r+x */
95 t
= a
= -(float)1.0/w
; /* a = -1.0/w */
97 SET_FLOAT_WORD(t
,i
&0xfffff000);