2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
6 #include "mathieeedoubtrans_intern.h"
8 /*****************************************************************************
12 AROS_LHQUAD1(double, IEEEDPSin
,
15 AROS_LHAQUAD(double, y
, D0
, D1
),
18 struct MathIeeeDoubTransBase
*, MathIeeeDoubTransBase
, 6, MathIeeeDoubTrans
)
21 Calculate the sine of a given IEEE double precision number in radians
26 IEEE double precision floating point number
30 negative : result is negative
36 Algorithm for Calculation of sin(y):
37 z = floor ( |y| / pi );
38 y_1 = |y| - z * pi; => 0 <= y_1 < pi
40 if (y_1 > pi/2 ) then y_1 = pi - y_1;
44 Res = y - y^3/3! + y^5/5! - y^7/7! + y^9/9! - y^11/11! =
45 = y(1+y^2(-1/3!+y^2(1/5!+y^2(-1/7!+y^2(1/9!-1/11!y^2)))));
50 if (z was an odd number)
53 *****************************************************************************/
57 QUAD z
,Res
,ysquared
,yabs
, Qtmp
;
61 (IEEEDPMantisse_Mask_Hi
| IEEEDPExponent_Mask_Hi
),
62 (IEEEDPMantisse_Mask_Lo
| IEEEDPExponent_Mask_Lo
)
65 if (is_eqC(yabs
, IEEEDPPInfty_Hi
, IEEEDPPInfty_Lo
))
67 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
68 Set_Value64C(Res
, IEEEDPNAN_Hi
, IEEEDPNAN_Lo
);
72 z
= IEEEDPFloor(IEEEDPDiv(yabs
, pi
));
73 Qtmp
= IEEEDPMul(z
,pi
);
74 OR64QC(Qtmp
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
) /* Qtmp=-Qtmp */
75 yabs
= IEEEDPAdd(yabs
, Qtmp
);
76 if (is_greaterC(yabs
, pio2_Hi
, pio2_Lo
))
78 OR64QC(Qtmp
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
) /* Qtmp=-Qtmp */
79 yabs
=IEEEDPAdd(pi
, yabs
);
81 ysquared
= IEEEDPMul(yabs
,yabs
);
96 IEEEDPMul(ysquared
, sinf8
)))))))))))))));
98 if (is_lessSC(y
, 0x0, 0x0) )
100 XOR64QC(Res
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
);
103 if (TRUE
== intern_IEEEDPisodd(z
))
105 XOR64QC(Res
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
);
108 if (is_eqC(Res
, 0x0, 0x0))
110 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
114 if (is_lessSC(Res
, 0x0 ,0x0))
116 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);