1 /* s_tanl.c -- long double version of s_tan.c.
2 * Conversion to long double by Ulrich Drepper,
3 * Cygnus Support, drepper@cygnus.com.
7 * ====================================================
8 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
10 * Developed at SunPro, a Sun Microsystems, Inc. business.
11 * Permission to use, copy, modify, and distribute this
12 * software is freely granted, provided that this notice
14 * ====================================================
17 #if defined(LIBM_SCCS) && !defined(lint)
18 static char rcsid[] = "$NetBSD: $";
22 * Return tangent function of x.
25 * __kernel_tanl ... tangent function on [-pi/4,pi/4]
26 * __ieee754_rem_pio2l ... argument reduction routine
29 * Let S,C and T denote the sin, cos and tan respectively on
30 * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
31 * in [-pi/4 , +pi/4], and let n = k mod 4.
34 * n sin(x) cos(x) tan(x)
35 * ----------------------------------------------------------
40 * ----------------------------------------------------------
43 * Let trig be any of sin, cos, or tan.
44 * trig(+-INF) is NaN, with signals;
45 * trig(NaN) is that NaN;
48 * TRIG(x) returns trig(x) nearly rounded
52 #include "math_private.h"
55 long double __tanl(long double x)
61 long double y[2],z=0.0;
65 GET_LDOUBLE_EXP(se,x);
69 if(se <= 0x3ffe) return __kernel_tanl(x,z,1);
71 /* tan(Inf or NaN) is NaN */
72 else if (se==0x7fff) return x-x; /* NaN */
74 /* argument reduction needed */
76 n = __ieee754_rem_pio2l(x,y);
77 return __kernel_tanl(y[0],y[1],1-((n&1)<<1)); /* 1 -- n even
81 weak_alias (__tanl, tanl)