Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / mathieeedoubtrans / ieeedpcosh.c
blob78668ea68e7cbb5c7a338240309eafed0c80f8ec
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathieeedoubtrans_intern.h"
8 /*
9 FUNCTION
10 Calculate the hyperbolic cosine of the IEEE single precision number
12 RESULT
13 IEEE single precision floating point number
15 flags:
16 zero : result is zero
17 negative : 0 (not possible)
18 overflow : result too big for ffp-number
20 NOTES
22 EXAMPLE
24 BUGS
26 SEE ALSO
28 INTERNALS
29 cosh(x) = (1/2)*( e^x + e^(-x) )
31 cosh( |x| >= 18 ) = (1/2) * (e^x);
33 HISTORY
36 AROS_LHQUAD1(double, IEEEDPCosh,
37 AROS_LHAQUAD(double, y, D0, D1),
38 struct MathIeeeDoubTransBase *, MathIeeeDoubTransBase, 11, MathIeeeDoubTrans
41 AROS_LIBFUNC_INIT
43 QUAD Res;
44 /* cosh(-x) = cosh(x) */
45 /* y &= ( IEEEDPMantisse_Mask + IEEEDPExponent_Mask ); */
46 AND64QC
48 y,
49 (IEEEDPMantisse_Mask_Hi + IEEEDPExponent_Mask_Hi),
50 (IEEEDPMantisse_Mask_Lo + IEEEDPExponent_Mask_Lo)
53 if ( is_eqC(y, IEEEDPPInfty_Hi, IEEEDPPInfty_Lo))
55 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
56 return y;
59 Res = IEEEDPExp(y);
61 if ( is_eqC(Res, IEEEDPPInfty_Hi, IEEEDPPInfty_Lo))
63 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
64 return Res;
67 /* does adding of 1/(e^x) still change the result? */
68 if ( is_lessC(y, 0x40320000, 0x0 ))
70 QUAD One;
71 Set_Value64C(One, 0x3ff00000, 0x0);
73 Res = IEEEDPAdd(Res, IEEEDPDiv(One, Res));
75 /* Res = Res / 2 */
76 ADD64QC(Res, 0xFFF00000, 0x0);
80 is_eqC(Res, 0x0, 0x0)
81 || is_lessSC(Res, 0x0, 0x0)
84 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
85 Set_Value64C(Res, 0x0, 0x0);
86 return Res;
88 return Res;
90 AROS_LIBFUNC_EXIT