1 /* s_tanl.c -- long double version of s_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: $";
20 * Return tangent function of x.
23 * __kernel_tanl ... tangent function on [-pi/4,pi/4]
24 * __ieee754_rem_pio2l ... argument reduction routine
27 * Let S,C and T denote the sin, cos and tan respectively on
28 * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
29 * in [-pi/4 , +pi/4], and let n = k mod 4.
32 * n sin(x) cos(x) tan(x)
33 * ----------------------------------------------------------
38 * ----------------------------------------------------------
41 * Let trig be any of sin, cos, or tan.
42 * trig(+-INF) is NaN, with signals;
43 * trig(NaN) is that NaN;
46 * TRIG(x) returns trig(x) nearly rounded
51 #include <math_private.h>
52 #include <libm-alias-ldouble.h>
54 long double __tanl(long double x
)
56 long double y
[2],z
=0.0;
57 int32_t n
, se
, i0
, i1
;
60 GET_LDOUBLE_WORDS(se
,i0
,i1
,x
);
64 if(se
<= 0x3ffe) return __kernel_tanl(x
,z
,1);
66 /* tan(Inf or NaN) is NaN */
67 else if (se
==0x7fff) {
68 if (i1
== 0 && i0
== 0x80000000)
73 /* argument reduction needed */
75 n
= __ieee754_rem_pio2l(x
,y
);
76 return __kernel_tanl(y
[0],y
[1],1-((n
&1)<<1)); /* 1 -- n even
80 libm_alias_ldouble (__tan
, tan
)