Listtree.mcc: implement proxying of DisplayHook
[AROS.git] / workbench / libs / mathieeedoubtrans / ieeedpcosh.c
blob674b37aee15817d11544ee8155b6beb8f5ea709c
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathieeedoubtrans_intern.h"
8 /*****************************************************************************
10 NAME */
12 AROS_LHQUAD1(double, IEEEDPCosh,
14 /* SYNOPSIS */
15 AROS_LHAQUAD(double, y, D0, D1),
17 /* LOCATION */
18 struct MathIeeeDoubTransBase *, MathIeeeDoubTransBase, 11, MathIeeeDoubTrans)
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| >= 18 ) = (1/2) * (e^x);
40 *****************************************************************************/
42 AROS_LIBFUNC_INIT
44 QUAD Res;
45 /* cosh(-x) = cosh(x) */
46 /* y &= ( IEEEDPMantisse_Mask + IEEEDPExponent_Mask ); */
47 AND64QC
49 y,
50 (IEEEDPMantisse_Mask_Hi + IEEEDPExponent_Mask_Hi),
51 (IEEEDPMantisse_Mask_Lo + IEEEDPExponent_Mask_Lo)
54 if ( is_eqC(y, IEEEDPPInfty_Hi, IEEEDPPInfty_Lo))
56 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
57 return y;
60 Res = IEEEDPExp(y);
62 if ( is_eqC(Res, IEEEDPPInfty_Hi, IEEEDPPInfty_Lo))
64 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
65 return Res;
68 /* does adding of 1/(e^x) still change the result? */
69 if ( is_lessC(y, 0x40320000, 0x0 ))
71 QUAD One;
72 Set_Value64C(One, 0x3ff00000, 0x0);
74 Res = IEEEDPAdd(Res, IEEEDPDiv(One, Res));
76 /* Res = Res / 2 */
77 ADD64QC(Res, 0xFFF00000, 0x0);
81 is_eqC(Res, 0x0, 0x0)
82 || is_lessSC(Res, 0x0, 0x0)
85 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
86 Set_Value64C(Res, 0x0, 0x0);
87 return Res;
89 return Res;
91 AROS_LIBFUNC_EXIT