2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
6 #include "mathieeedoubtrans_intern.h"
8 /*****************************************************************************
12 AROS_LHQUAD1(double, IEEEDPCos
,
15 AROS_LHAQUAD(double, y
, D0
, D1
),
18 struct MathIeeeDoubTransBase
*, MathIeeeDoubTransBase
, 7, MathIeeeDoubTrans
)
21 Calculate the cosine of a given IEEE double precision number in radians
26 IEEE double precision floating point number
30 negative : result is negative
36 cos (x) = sin (x+ pi/2);
38 *****************************************************************************/
43 QUAD z
,Res
, ysquared
, yabs
, Qtmp
;
47 (IEEEDPMantisse_Mask_Hi
| IEEEDPExponent_Mask_Hi
),
48 (IEEEDPMantisse_Mask_Lo
| IEEEDPExponent_Mask_Lo
)
51 if (is_eqC(yabs
, IEEEDPPInfty_Hi
, IEEEDPPInfty_Lo
))
53 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
54 Set_Value64C(Res
, IEEEDPNAN_Hi
, IEEEDPNAN_Lo
);
58 z
= IEEEDPFloor(IEEEDPDiv(yabs
, pi
));
59 Qtmp
= IEEEDPMul(z
,pi
);
60 OR64QC(Qtmp
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
) /* Qtmp=-Qtmp */
61 yabs
= IEEEDPAdd(yabs
, Qtmp
);
62 if (is_greaterC(yabs
, pio2_Hi
, pio2_Lo
))
64 OR64QC(Qtmp
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
) /* Qtmp=-Qtmp */
65 yabs
=IEEEDPAdd(pi
, yabs
);
73 ysquared
= IEEEDPMul(yabs
,yabs
);
74 Res
= IEEEDPAdd(cosf1
,
87 IEEEDPMul(ysquared
, cosf8
))))))))))))));
89 if (is_eqC(Res
, 0x0, 0x0))
91 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
92 Set_Value64C(Res
, 0x0, 0x0);
96 if (TRUE
== intern_IEEEDPisodd(z
))
98 XOR64QC(Res
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
);
103 XOR64QC(Res
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
);
106 if (is_lessSC(Res
, 0x0, 0x0))
108 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);