revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / mathieeesingtrans / ieeespcosh.c
blob9cdfad5dfeba30e4ce0d3272a75ae1f73a1e0fcc
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathieeesingtrans_intern.h"
8 /*****************************************************************************
10 NAME */
12 AROS_LH1(float, IEEESPCosh,
14 /* SYNOPSIS */
15 AROS_LHA(float, y, D0),
17 /* LOCATION */
18 struct Library *, MathIeeeSingTransBase, 11, MathIeeeSingTrans)
20 /* FUNCTION
21 Calculate the hyperbolic cosine of the IEEE single precision number
23 INPUTS
25 RESULT
26 IEEE single precision floating point number
28 flags:
29 zero : result is zero
30 negative : 0 (not possible)
31 overflow : result too big for ffp-number
33 BUGS
35 INTERNALS
36 cosh(x) = (1/2)*( e^x + e^(-x) )
38 cosh( |x| >= 9 ) = (1/2) * (e^x);
40 *****************************************************************************/
42 AROS_LIBFUNC_INIT
44 LONG Res;
45 /* cosh(-x) = cosh(x) */
46 y &= ( IEEESPMantisse_Mask + IEEESPExponent_Mask );
48 if ( IEEESP_Pinfty == y)
50 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
51 return y;
54 Res = IEEESPExp(y);
56 if ( IEEESP_Pinfty == Res )
58 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
59 return 0x7f000000; /* Res; */
62 if ( y < 0x41100000 ) Res = IEEESPAdd(Res, IEEESPDiv(one, Res));
64 /* Res = Res / 2 */
65 Res -= 0x00800000;
67 if ( 0 == Res || Res < 0 )
69 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
70 return 0;
73 return Res;
75 AROS_LIBFUNC_EXIT