childs -> children.
[AROS.git] / workbench / libs / mathieeesingtrans / ieeespcosh.c
blobc5a30ff757c83273721dec1c4bf1f521a6f80fd2
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathieeesingtrans_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 <code>
30 cosh(x) = (1/2)*( e^x + e^(-x) )
32 cosh( |x| >= 9 ) = (1/2) * (e^x);
33 </code>
35 HISTORY
38 AROS_LH1(float, IEEESPCosh,
39 AROS_LHA(float, y, D0),
40 struct Library *, MathIeeeSingTransBase, 11, MathIeeeSingTrans
43 AROS_LIBFUNC_INIT
45 LONG Res;
46 /* cosh(-x) = cosh(x) */
47 y &= ( IEEESPMantisse_Mask + IEEESPExponent_Mask );
49 if ( IEEESP_Pinfty == y)
51 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
52 return y;
55 Res = IEEESPExp(y);
57 if ( IEEESP_Pinfty == Res )
59 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
60 return 0x7f000000; /* Res; */
63 if ( y < 0x41100000 ) Res = IEEESPAdd(Res, IEEESPDiv(one, Res));
65 /* Res = Res / 2 */
66 Res -= 0x00800000;
68 if ( 0 == Res || Res < 0 )
70 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
71 return 0;
74 return Res;
76 AROS_LIBFUNC_EXIT