delint
[AROS.git] / workbench / libs / mathtrans / spsinh.c
blob49018fb978f3553d1c2c7b2b66489cabfa776859
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathtrans_intern.h"
8 /*****************************************************************************
10 NAME */
12 AROS_LH1(float, SPSinh,
14 /* SYNOPSIS */
15 AROS_LHA(float, fnum1, D0),
17 /* LOCATION */
18 struct Library *, MathTransBase, 10, MathTrans)
20 /* FUNCTION
21 Calculate the hyperbolic sine of the ffp number
23 INPUTS
25 RESULT
26 Motorola fast floating point number
28 flags:
29 zero : result is zero
30 negative : result is negative
31 overflow : result is too big for ffp format
33 BUGS
35 INTERNALS
36 sinh(x) = (1/2)*( e^x- e^(-x) )
38 sinh( |x| >= 44 ) = infinity;
39 sinh( |x| >= 9 ) = (1/2) * (e^x);
41 *****************************************************************************/
43 AROS_LIBFUNC_INIT
45 ULONG Res;
46 LONG tmp;
48 /* sinh(-x) = -sinh(x) */
49 Res = SPExp(fnum1 & (FFPMantisse_Mask + FFPExponent_Mask) );
51 if ( FFP_Pinfty == Res )
53 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
54 return Res;
57 tmp = (fnum1 & FFPExponent_Mask) - 0x41;
59 if ( tmp <= 2 || (tmp == 3 && (fnum1 & FFPMantisse_Mask) < 0x90000000) )
61 Res = SPAdd(Res, ((ULONG)SPDiv(Res, one) | FFPSign_Mask ));
64 /* Res = Res / 2 */
66 /* should be (char(Res))-- , but gcc on Linux screws up the result! */
68 tmp = Res & 0xFFFFFF00;
69 Res -= sizeof(char);
70 Res = Res | tmp;
72 if ( 0 == Res || (char)Res < 0 )
74 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
75 return 0;
78 /* if the argument was negative, the result is also negative */
79 if ((char)fnum1 < 0 )
81 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
82 return (Res | FFPSign_Mask);
85 return Res;
87 AROS_LIBFUNC_EXIT