2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
6 #include "mathtrans_intern.h"
8 /*****************************************************************************
12 AROS_LH1(float, SPSin
,
15 AROS_LHA(float, fnum1
, D0
),
18 struct Library
*, MathTransBase
, 6, MathTrans
)
21 Calculate the sine of a given FFP number in radians
26 Motorola fast floating point number
30 negative : result is negative
36 Algorithm for Calculation of sin(y):
38 z = floor ( |y| / pi );
39 y_1 = |y| - z * pi; => 0 <= y_1 < pi
41 if (y_1 > pi/2 ) then y_1 = pi - y_1;
45 Res = y - y^3/3! + y^5/5! - y^7/7! + y^9/9! - y^11/11! =
46 = y(1+y^2(-1/3!+y^2(1/5!+y^2(-1/7!+y^2(1/9!-1/11!y^2)))));
51 if (z was an odd number)
54 *****************************************************************************/
58 LONG z
,Res
,ysquared
,yabs
,tmp
;
59 yabs
= fnum1
& (FFPMantisse_Mask
+ FFPExponent_Mask
);
61 if ((LONG
)FFP_Pinfty
== yabs
)
63 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
67 z
= SPFloor(SPDiv(pi
, yabs
));
69 tmp
|= FFPSign_Mask
; /* tmp = -tmp; */
70 yabs
= SPAdd(yabs
, tmp
);
72 if ( (char)yabs
> (char)pio2
&& (yabs
& FFPMantisse_Mask
) > (pio2
& FFPMantisse_Mask
) )
75 yabs
= SPAdd(pi
, yabs
);
77 ysquared
= SPMul(yabs
,yabs
);
88 SPMul(ysquared
, sinf6
)))))))))));
90 if ((char)fnum1
< 0 ) Res
^= FFPSign_Mask
;
92 if (TRUE
== intern_SPisodd(z
)) Res
^= FFPSign_Mask
;
96 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
102 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);