Copyright clean-up (part 1):
[AROS.git] / compiler / stdc / math / sincos.c
blob70f8b594835aac3a7ddeed91da00a12f6e993de4
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
8 #include "math.h"
9 #include "math_private.h"
11 void sincos(double x, double *sin, double *cos)
13 double y[2],z=0.0;
14 int32_t n, ix;
16 /* High word of x. */
17 GET_HIGH_WORD(ix,x);
19 /* |x| ~< pi/4 */
20 ix &= 0x7fffffff;
21 if(ix <= 0x3fe921fb) {
22 if(ix<0x3e400000) /* |x| < 2**-27 */
23 {if((int)x==0) { *sin=x; *cos=1.0; return; }} /* generate inexact */
24 *sin = __kernel_sin(x,z,0);
25 *cos = __kernel_cos(x,z);
26 return;
29 /* cos(Inf or NaN) is NaN */
30 else if (ix>=0x7ff00000) {*sin = *cos = x-x; return; }
32 /* argument reduction needed */
33 else {
34 n = __ieee754_rem_pio2(x,y);
35 switch(n&3) {
36 case 0: *sin = __kernel_sin(y[0],y[1],1); *cos = __kernel_cos(y[0],y[1]); break;
37 case 1: *sin = __kernel_cos(y[0],y[1]); *cos = -__kernel_sin(y[0],y[1],1); break;
38 case 2: *sin = -__kernel_sin(y[0],y[1],1); *cos = -__kernel_cos(y[0],y[1]); break;
39 default:
40 *sin = -__kernel_cos(y[0],y[1]); *cos = __kernel_sin(y[0],y[1],1);