1 /* origin: FreeBSD /usr/src/lib/msun/src/s_sin.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 sine function of x.
16 * __sin ... sine function on [-pi/4,pi/4]
17 * __cos ... cose function on [-pi/4,pi/4]
18 * __rem_pio2 ... argument reduction routine
21 * Let S,C and T denote the sin, cos and tan respectively on
22 * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
23 * in [-pi/4 , +pi/4], and let n = k mod 4.
26 * n sin(x) cos(x) tan(x)
27 * ----------------------------------------------------------
32 * ----------------------------------------------------------
35 * Let trig be any of sin, cos, or tan.
36 * trig(+-INF) is NaN, with signals;
37 * trig(NaN) is that NaN;
40 * TRIG(x) returns trig(x) nearly rounded
56 if (ix <= 0x3fe921fb) {
57 if (ix < 0x3e500000) { /* |x| < 2**-26 */
58 /* raise inexact if x != 0 and underflow if subnormal*/
59 FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f);
62 return __sin(x, 0.0, 0);
65 /* sin(Inf or NaN) is NaN */
69 /* argument reduction needed */
72 case 0: return __sin(y[0], y[1], 1);
73 case 1: return __cos(y[0], y[1]);
74 case 2: return -__sin(y[0], y[1], 1);
76 return -__cos(y[0], y[1]);