2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
6 #include "mathieeesingtrans_intern.h"
8 /*****************************************************************************
12 AROS_LH1(float, IEEESPSin
,
15 AROS_LHA(float, y
, D0
),
18 struct Library
*, MathIeeeSingTransBase
, 6, MathIeeeSingTrans
)
21 Calculate the sine of a given IEEE single precision number in radians
26 IEEE single precision 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
= y
& (IEEESPMantisse_Mask
+ IEEESPExponent_Mask
);
61 if (IEEESP_Pinfty
== yabs
)
63 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
67 z
= IEEESPFloor(IEEESPDiv(yabs
, pi
));
68 tmp
= IEEESPMul(z
,pi
);
69 tmp
|= IEEESPSign_Mask
; /* tmp = -tmp; */
70 yabs
= IEEESPAdd(yabs
, tmp
);
73 yabs
|= IEEESPSign_Mask
;
74 yabs
=IEEESPAdd(pi
, yabs
);
76 ysquared
= IEEESPMul(yabs
,yabs
);
87 IEEESPMul(ysquared
, sinf6
)))))))))));
89 if (y
< 0 ) Res
^= IEEESPSign_Mask
;
90 if (TRUE
== intern_IEEESPisodd(z
)) Res
^= IEEESPSign_Mask
;
94 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
98 if (Res
< 0) SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);