Removed obsolete (and apparently unneeded) AM_C_PROTOTYPES line, which
[AROS.git] / compiler / mlib / sincos.c
blobccbf9b7aa31ae5afc90341c3f45469e5efbfad85
2 #include <aros/debug.h>
4 #include "math.h"
5 #include "math_private.h"
7 void sincos(double x, double *sin, double *cos)
9 double y[2],z=0.0;
10 int32_t n, ix;
12 /* High word of x. */
13 GET_HIGH_WORD(ix,x);
15 /* |x| ~< pi/4 */
16 ix &= 0x7fffffff;
17 if(ix <= 0x3fe921fb) {
18 if(ix<0x3e400000) /* |x| < 2**-27 */
19 {if((int)x==0) { *sin=x; *cos=1.0; return; }} /* generate inexact */
20 *sin = __kernel_sin(x,z,0);
21 *cos = __kernel_cos(x,z);
22 return;
25 /* cos(Inf or NaN) is NaN */
26 else if (ix>=0x7ff00000) {*sin = *cos = x-x; return; }
28 /* argument reduction needed */
29 else {
30 n = __ieee754_rem_pio2(x,y);
31 switch(n&3) {
32 case 0: *sin = __kernel_sin(y[0],y[1],1); *cos = __kernel_cos(y[0],y[1]); break;
33 case 1: *sin = __kernel_cos(y[0],y[1]); *cos = -__kernel_sin(y[0],y[1],1); break;
34 case 2: *sin = -__kernel_sin(y[0],y[1],1); *cos = -__kernel_cos(y[0],y[1]); break;
35 default:
36 *sin = -__kernel_cos(y[0],y[1]); *cos = __kernel_sin(y[0],y[1],1);