1 /* origin: FreeBSD /usr/src/lib/msun/src/s_tan.c */
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
10 * ====================================================
13 * Return tangent function of x.
16 * __tan ... tangent function on [-pi/4,pi/4]
17 * __rem_pio2 ... argument reduction routine
20 * Let S,C and T denote the sin, cos and tan respectively on
21 * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
22 * in [-pi/4 , +pi/4], and let n = k mod 4.
25 * n sin(x) cos(x) tan(x)
26 * ----------------------------------------------------------
31 * ----------------------------------------------------------
34 * Let trig be any of sin, cos, or tan.
35 * trig(+-INF) is NaN, with signals;
36 * trig(NaN) is that NaN;
39 * TRIG(x) returns trig(x) nearly rounded
54 if (ix <= 0x3fe921fb) {
55 if (ix < 0x3e400000) /* x < 2**-27 */
56 /* raise inexact if x != 0 */
59 return __tan(x, z, 1);
62 /* tan(Inf or NaN) is NaN */
66 /* argument reduction needed */
68 return __tan(y[0], y[1], 1 - ((n&1)<<1)); /* n even: 1, n odd: -1 */