2 /* @(#)s_sin.c 5.1 93/09/24 */
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 * Developed at SunPro, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
11 * ====================================================
16 <<sin>>, <<sinf>>, <<cos>>, <<cosf>>---sine or cosine
27 double sin(double <[x]>);
28 float sinf(float <[x]>);
29 double cos(double <[x]>);
30 float cosf(float <[x]>);
45 <<sin>> and <<cos>> compute (respectively) the sine and cosine
46 of the argument <[x]>. Angles are specified in radians.
48 <<sinf>> and <<cosf>> are identical, save that they take and
49 return <<float>> values.
53 The sine or cosine of <[x]> is returned.
56 <<sin>> and <<cos>> are ANSI C.
57 <<sinf>> and <<cosf>> are extensions.
65 * Return sine function of x.
68 * __kernel_sin ... sine function on [-pi/4,pi/4]
69 * __kernel_cos ... cose function on [-pi/4,pi/4]
70 * __ieee754_rem_pio2 ... argument reduction routine
73 * Let S,C and T denote the sin, cos and tan respectively on
74 * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
75 * in [-pi/4 , +pi/4], and let n = k mod 4.
78 * n sin(x) cos(x) tan(x)
79 * ----------------------------------------------------------
84 * ----------------------------------------------------------
87 * Let trig be any of sin, cos, or tan.
88 * trig(+-INF) is NaN, with signals;
89 * trig(NaN) is that NaN;
92 * TRIG(x) returns trig(x) nearly rounded
97 #ifndef _DOUBLE_IS_32BITS
109 /* High word of x. */
114 if(ix
<= 0x3fe921fb) return __kernel_sin(x
,z
,0);
116 /* sin(Inf or NaN) is NaN */
117 else if (ix
>=0x7ff00000) return x
-x
;
119 /* argument reduction needed */
121 n
= __ieee754_rem_pio2(x
,y
);
123 case 0: return __kernel_sin(y
[0],y
[1],1);
124 case 1: return __kernel_cos(y
[0],y
[1]);
125 case 2: return -__kernel_sin(y
[0],y
[1],1);
127 return -__kernel_cos(y
[0],y
[1]);
132 #endif /* _DOUBLE_IS_32BITS */