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.
18 #include <sys/cdefs.h>
19 __FBSDID("$FreeBSD$");
24 #define INLINE_REM_PIO2F
25 #include "math_private.h"
26 #include "e_rem_pio2f.c"
27 #include "k_sincosf.h"
29 /* Small multiples of pi/2 rounded to double precision. */
31 p1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
32 p2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
33 p3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
34 p4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
37 sincosf(float x, float *sn, float *cs)
43 GET_FLOAT_WORD(hx, x);
46 if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
47 if (ix < 0x39800000) { /* |x| < 2**-12 */
49 *sn = x; /* x with inexact if x != 0 */
54 __kernel_sincosdf(x, sn, cs);
58 if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
59 if (ix <= 0x4016cbe3) { /* |x| ~<= 3pi/4 */
61 __kernel_sincosdf(x - p1pio2, cs, sn);
64 __kernel_sincosdf(x + p1pio2, cs, sn);
69 __kernel_sincosdf(x - p2pio2, sn, cs);
71 __kernel_sincosdf(x + p2pio2, sn, cs);
78 if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
79 if (ix <= 0x40afeddf) { /* |x| ~<= 7*pi/4 */
81 __kernel_sincosdf(x - p3pio2, cs, sn);
84 __kernel_sincosdf(x + p3pio2, cs, sn);
89 __kernel_sincosdf(x - p4pio2, sn, cs);
91 __kernel_sincosdf(x + p4pio2, sn, cs);
96 /* If x = Inf or NaN, then sin(x) = NaN and cos(x) = NaN. */
97 if (ix >= 0x7f800000) {
103 /* Argument reduction. */
104 n = __ieee754_rem_pio2f(x, &y);
105 __kernel_sincosdf(y, &s, &c);