2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
6 #include "mathieeedoubtrans_intern.h"
10 Calculate the sine of a given IEEE double precision number in radians
13 IEEE double precision floating point number
17 negative : result is negative
29 Algorithm for Calculation of sin(y):
31 z = floor ( |y| / pi );
32 y_1 = |y| - z * pi; => 0 <= y_1 < pi
34 if (y_1 > pi/2 ) then y_1 = pi - y_1;
38 Res = y - y^3/3! + y^5/5! - y^7/7! + y^9/9! - y^11/11! =
39 = y(1+y^2(-1/3!+y^2(1/5!+y^2(-1/7!+y^2(1/9!-1/11!y^2)))));
44 if (z was an odd number)
51 AROS_LHQUAD1(double, IEEEDPSin
,
52 AROS_LHAQUAD(double, y
, D0
, D1
),
53 struct MathIeeeDoubTransBase
*, MathIeeeDoubTransBase
, 6, MathIeeeDoubTrans
58 QUAD z
,Res
,ysquared
,yabs
, Qtmp
;
62 (IEEEDPMantisse_Mask_Hi
| IEEEDPExponent_Mask_Hi
),
63 (IEEEDPMantisse_Mask_Lo
| IEEEDPExponent_Mask_Lo
)
66 if (is_eqC(yabs
, IEEEDPPInfty_Hi
, IEEEDPPInfty_Lo
))
68 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
69 Set_Value64C(Res
, IEEEDPNAN_Hi
, IEEEDPNAN_Lo
);
73 z
= IEEEDPFloor(IEEEDPDiv(yabs
, pi
));
74 Qtmp
= IEEEDPMul(z
,pi
);
75 OR64QC(Qtmp
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
) /* Qtmp=-Qtmp */
76 yabs
= IEEEDPAdd(yabs
, Qtmp
);
77 if (is_greaterC(yabs
, pio2_Hi
, pio2_Lo
))
79 OR64QC(Qtmp
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
) /* Qtmp=-Qtmp */
80 yabs
=IEEEDPAdd(pi
, yabs
);
82 ysquared
= IEEEDPMul(yabs
,yabs
);
97 IEEEDPMul(ysquared
, sinf8
)))))))))))))));
99 if (is_lessSC(y
, 0x0, 0x0) )
101 XOR64QC(Res
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
);
104 if (TRUE
== intern_IEEEDPisodd(z
))
106 XOR64QC(Res
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
);
109 if (is_eqC(Res
, 0x0, 0x0))
111 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
115 if (is_lessSC(Res
, 0x0 ,0x0))
117 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);