2 * ====================================================
3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 * Developed at SunPro, a Sun Microsystems, Inc. business.
6 * Permission to use, copy, modify, and distribute this
7 * software is freely granted, provided that this notice
9 * ====================================================
12 /* s_sincosf.c -- float version of s_sincos.c.
13 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
14 * Optimized by Bruce D. Evans.
15 * Merged s_sinf.c and s_cosf.c by Steven G. Kargl.
21 #include "math_private.h"
22 #include "k_sincosf.h"
24 /* Small multiples of pi/2 rounded to double precision. */
26 p1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
27 p2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
28 p3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
29 p4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
32 sincosf(float x, float *sn, float *cs)
38 GET_FLOAT_WORD(hx, x);
41 if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
42 if (ix < 0x39800000) { /* |x| < 2**-12 */
44 *sn = x; /* x with inexact if x != 0 */
49 __kernel_sincosdf(x, sn, cs);
53 if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
54 if (ix <= 0x4016cbe3) { /* |x| ~<= 3pi/4 */
56 __kernel_sincosdf(x - p1pio2, cs, sn);
59 __kernel_sincosdf(x + p1pio2, cs, sn);
64 __kernel_sincosdf(x - p2pio2, sn, cs);
66 __kernel_sincosdf(x + p2pio2, sn, cs);
73 if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
74 if (ix <= 0x40afeddf) { /* |x| ~<= 7*pi/4 */
76 __kernel_sincosdf(x - p3pio2, cs, sn);
79 __kernel_sincosdf(x + p3pio2, cs, sn);
84 __kernel_sincosdf(x - p4pio2, sn, cs);
86 __kernel_sincosdf(x + p4pio2, sn, cs);
91 /* If x = Inf or NaN, then sin(x) = NaN and cos(x) = NaN. */
92 if (ix >= 0x7f800000) {
98 /* Argument reduction. */
99 n = __ieee754_rem_pio2f(x, y);
100 s = __kernel_sinf(y[0], y[1], 1);
101 c = __kernel_cosf(y[0], y[1]);