grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / mathieeedoubtrans / ieeedpsinh.c
blobde39487ec3fcc98a70f2f9e2980dd03d46bbf9d4
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, IEEEDPSinh,
14 /* SYNOPSIS */
15 AROS_LHAQUAD(double, y, D0, D1),
17 /* LOCATION */
18 struct MathIeeeDoubTransBase *, MathIeeeDoubTransBase, 10, MathIeeeDoubTrans)
20 /* FUNCTION
21 Calculate the hyperbolic sine of the IEEE double precision number
23 INPUTS
25 RESULT
26 IEEE double precision floating point number
28 flags:
29 zero : result is zero
30 negative : result is negative
31 overflow : result is too big for IEEE double precsion format
33 BUGS
35 INTERNALS
36 sinh(x) = (1/2)*( e^x- e^(-x) )
38 sinh( |x| >= 18 ) = (1/2) * (e^x);
40 *****************************************************************************/
42 AROS_LIBFUNC_INIT
44 QUAD Res;
45 QUAD y2;
47 /* y2 = y & (IEEEDPMantisse_Mask + IEEEDPExponent_Mask); */
48 Set_Value64(y2, y);
49 AND64QC
51 y2,
52 (IEEEDPMantisse_Mask_Hi + IEEEDPExponent_Mask_Hi),
53 (IEEEDPMantisse_Mask_Lo + IEEEDPExponent_Mask_Lo)
56 if ( is_eqC(y, IEEEDPPInfty_Hi, IEEEDPPInfty_Lo))
58 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
59 return y;
62 /* sinh(-x) = -sinh(x) */
63 Res = IEEEDPExp(y2);
65 if ( is_eqC(Res, IEEEDPPInfty_Hi, IEEEDPPInfty_Lo ))
67 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
68 if ( is_lessSC(y, 0x0, 0x0))
70 OR64QC(Res, IEEEDPSign_Mask_Hi, IEEEDPSign_Mask_Lo );
72 return Res;
75 if ( is_lessC(y2, 0x40320000, 0x0) )
77 QUAD One, ResTmp;
78 Set_Value64C(One, one_Hi, one_Lo);
79 ResTmp = IEEEDPDiv(One, Res);
80 OR64QC(ResTmp, IEEEDPSign_Mask_Hi, IEEEDPSign_Mask_Lo);
82 Res = IEEEDPAdd(Res, ResTmp);
84 /* Res = Res / 2 */
85 ADD64QC(Res, 0xFFF00000, 0x0);
87 /* at this point Res has to be positive to be valid */
88 if ( is_leqSC(Res, 0x0, 0x0))
90 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
91 AND64QC(y, IEEEDPSign_Mask_Hi, IEEEDPSign_Mask_Lo);
92 return y;
95 if ( is_lessSC(y, 0x0, 0x0))
97 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
98 OR64QC(Res, IEEEDPSign_Mask_Hi, IEEEDPSign_Mask_Lo );
100 return Res;
103 return Res;
105 AROS_LIBFUNC_EXIT