Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / mathieeedoubtrans / ieeedpsinh.c
bloba0971a1d224774067af977df8441e169d16816c4
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 sine of the IEEE double precision number
12 RESULT
13 IEEE double precision floating point number
15 flags:
16 zero : result is zero
17 negative : result is negative
18 overflow : result is too big for IEEE double precsion format
20 NOTES
22 EXAMPLE
24 BUGS
26 SEE ALSO
28 INTERNALS
29 <code>
30 sinh(x) = (1/2)*( e^x- e^(-x) )
32 sinh( |x| >= 18 ) = (1/2) * (e^x);
33 </code>
35 HISTORY
38 AROS_LHQUAD1(double, IEEEDPSinh,
39 AROS_LHAQUAD(double, y, D0, D1),
40 struct MathIeeeDoubTransBase *, MathIeeeDoubTransBase, 10, MathIeeeDoubTrans
43 AROS_LIBFUNC_INIT
45 QUAD Res;
46 QUAD y2;
48 /* y2 = y & (IEEEDPMantisse_Mask + IEEEDPExponent_Mask); */
49 Set_Value64(y2, y);
50 AND64QC
52 y2,
53 (IEEEDPMantisse_Mask_Hi + IEEEDPExponent_Mask_Hi),
54 (IEEEDPMantisse_Mask_Lo + IEEEDPExponent_Mask_Lo)
57 if ( is_eqC(y, IEEEDPPInfty_Hi, IEEEDPPInfty_Lo))
59 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
60 return y;
63 /* sinh(-x) = -sinh(x) */
64 Res = IEEEDPExp(y2);
66 if ( is_eqC(Res, IEEEDPPInfty_Hi, IEEEDPPInfty_Lo ))
68 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
69 if ( is_lessSC(y, 0x0, 0x0))
71 OR64QC(Res, IEEEDPSign_Mask_Hi, IEEEDPSign_Mask_Lo );
73 return Res;
76 if ( is_lessC(y2, 0x40320000, 0x0) )
78 QUAD One, ResTmp;
79 Set_Value64C(One, one_Hi, one_Lo);
80 ResTmp = IEEEDPDiv(One, Res);
81 OR64QC(ResTmp, IEEEDPSign_Mask_Hi, IEEEDPSign_Mask_Lo);
83 Res = IEEEDPAdd(Res, ResTmp);
85 /* Res = Res / 2 */
86 ADD64QC(Res, 0xFFF00000, 0x0);
88 /* at this point Res has to be positive to be valid */
89 if ( is_leqSC(Res, 0x0, 0x0))
91 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
92 AND64QC(y, IEEEDPSign_Mask_Hi, IEEEDPSign_Mask_Lo);
93 return y;
96 if ( is_lessSC(y, 0x0, 0x0))
98 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
99 OR64QC(Res, IEEEDPSign_Mask_Hi, IEEEDPSign_Mask_Lo );
101 return Res;
104 return Res;
106 AROS_LIBFUNC_EXIT