1 /* s_sincosf.c -- float version of s_sincos.c
3 * Copyright (C) 2013 Elliot Saba
4 * Developed at the University of Washington
6 * Permission to use, copy, modify, and distribute this
7 * software is freely granted, provided that this notice
9 * ====================================================
12 #include <aros/debug.h>
15 #define INLINE_REM_PIO2F
16 #include "math_private.h"
17 #include "e_rem_pio2f.c"
18 #include "k_sincosf.h"
20 /* Small multiples of pi/2 rounded to double precision. */
22 p1pio2
= 1*M_PI_2
, /* 0x3FF921FB, 0x54442D18 */
23 p2pio2
= 2*M_PI_2
, /* 0x400921FB, 0x54442D18 */
24 p3pio2
= 3*M_PI_2
, /* 0x4012D97C, 0x7F3321D2 */
25 p4pio2
= 4*M_PI_2
; /* 0x401921FB, 0x54442D18 */
28 sincosf(float x
, float *sn
, float *cs
)
37 if(ix
<= 0x3f490fda) { /* |x| ~<= pi/4 */
38 if(ix
<0x39800000) { /* |x| < 2**-12 */
40 *sn
= x
; /* x with inexact if x != 0 */
45 __kernel_sincosdf(x
, sn
, cs
);
49 if (ix
<= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
50 if (ix
<= 0x4016cbe3) { /* |x| ~<= 3pi/4 */
52 __kernel_sincosdf(x
- p1pio2
, cs
, sn
);
55 __kernel_sincosdf(x
+ p1pio2
, cs
, sn
);
60 __kernel_sincosdf(x
- p2pio2
, sn
, cs
);
62 __kernel_sincosdf(x
+ p2pio2
, sn
, cs
);
69 if (ix
<= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
70 if (ix
<= 0x40afeddf) { /* |x| ~<= 7*pi/4 */
72 __kernel_sincosdf(x
- p3pio2
, cs
, sn
);
75 __kernel_sincosdf(x
+ p3pio2
, cs
, sn
);
80 __kernel_sincosdf(x
- p4pio2
, sn
, cs
);
82 __kernel_sincosdf(x
+ p4pio2
, sn
, cs
);
87 /* If x = Inf or NaN, then sin(x) = NaN and cos(x) = NaN. */
88 if (ix
>= 0x7f800000) {
94 /* Argument reduction. */
95 n
= __ieee754_rem_pio2f(x
,&y
);
96 __kernel_sincosdf(y
, &s
, &c
);