2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
6 #include "mathieeedoubtrans_intern.h"
10 Calculate the cosine of a given IEEE double precision number in radians
13 IEEE double precision floating point number
17 negative : result is negative
29 cos (x) = sin (x+ pi/2);
34 AROS_LHQUAD1(double, IEEEDPCos
,
35 AROS_LHAQUAD(double, y
, D0
, D1
),
36 struct MathIeeeDoubTransBase
*, MathIeeeDoubTransBase
, 7, MathIeeeDoubTrans
42 QUAD z
,Res
, ysquared
, yabs
, Qtmp
;
46 (IEEEDPMantisse_Mask_Hi
| IEEEDPExponent_Mask_Hi
),
47 (IEEEDPMantisse_Mask_Lo
| IEEEDPExponent_Mask_Lo
)
50 if (is_eqC(yabs
, IEEEDPPInfty_Hi
, IEEEDPPInfty_Lo
))
52 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
53 Set_Value64C(Res
, IEEEDPNAN_Hi
, IEEEDPNAN_Lo
);
57 z
= IEEEDPFloor(IEEEDPDiv(yabs
, pi
));
58 Qtmp
= IEEEDPMul(z
,pi
);
59 OR64QC(tmp
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
) /* Qtmp=-Qtmp */
60 yabs
= IEEEDPAdd(yabs
, Qtmp
);
61 if (is_greaterC(yabs
, pio2_Hi
, pio2_Lo
))
63 OR64QC(Qtmp
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
) /* Qtmp=-Qtmp */
64 yabs
=IEEEDPAdd(pi
, yabs
);
72 ysquared
= IEEEDPMul(yabs
,yabs
);
73 Res
= IEEEDPAdd(cosf1
,
86 IEEEDPMul(ysquared
, cosf8
))))))))))))));
88 if (is_eqC(Res
, 0x0, 0x0))
90 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
91 Set_Value64C(Res
, 0x0, 0x0);
95 if (TRUE
== intern_IEEEDPisodd(z
))
97 XOR64QC(Res
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
);
102 XOR64QC(Res
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
);
105 if (is_lessSC(Res
, 0x0, 0x0))
107 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);