Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / mathtrans / spcosh.c
blob6c9688bd15486b0c448b9e9e313f81f6e92facc0
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathtrans_intern.h"
8 /*
9 FUNCTION
10 Calculate the hyperbolic cosine of the ffp number
12 RESULT
13 Motorola fast 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| >= 44 ) = infinity;
33 cosh( |x| >= 9 ) = (1/2) * (e^x);
34 </code>
36 HISTORY
39 AROS_LH1(float, SPCosh,
40 AROS_LHA(float, fnum1, D0),
41 struct Library *, MathTransBase, 11, MathTrans
44 AROS_LIBFUNC_INIT
46 ULONG Res;
47 LONG tmp;
49 /* cosh(-x) = cosh(x) */
50 fnum1 &= ( FFPMantisse_Mask + FFPExponent_Mask );
52 Res = SPExp(fnum1);
54 if ( FFP_Pinfty == Res )
56 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
57 return Res;
60 tmp = (fnum1 & FFPExponent_Mask) - 0x41;
62 if ( tmp <= 2 || (tmp == 3 && (fnum1 & FFPMantisse_Mask) < 0x90000000) )
64 Res = SPAdd(Res, SPDiv(Res, one));
67 /* Res = Res / 2 */
68 /* should be ((char)Res) --, but gcc on Linux screws up the result */
69 tmp = Res & 0xFFFFFF00;
70 Res -= sizeof(char);
71 Res = tmp | Res;
73 if (0 == Res || (char)Res < 0 )
75 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
76 return 0;
79 return Res;
81 AROS_LIBFUNC_EXIT