added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / libs / mathtrans / spsinh.c
blob0299ce446a2eb3ede82a23c20b4fd4b7846016dd
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 sine of the ffp number
12 RESULT
13 Motorola fast floating point number
15 flags:
16 zero : result is zero
17 negative : result is negative
18 overflow : result is too big for ffp format
20 NOTES
22 EXAMPLE
24 BUGS
26 SEE ALSO
28 INTERNALS
29 sinh(x) = (1/2)*( e^x- e^(-x) )
31 sinh( |x| >= 44 ) = infinity;
32 sinh( |x| >= 9 ) = (1/2) * (e^x);
34 HISTORY
37 AROS_LH1(float, SPSinh,
38 AROS_LHA(float, fnum1, D0),
39 struct Library *, MathTransBase, 10, MathTrans
42 AROS_LIBFUNC_INIT
44 ULONG Res;
45 LONG tmp;
47 /* sinh(-x) = -sinh(x) */
48 Res = SPExp(fnum1 & (FFPMantisse_Mask + FFPExponent_Mask) );
50 if ( FFP_Pinfty == Res )
52 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
53 return Res;
56 tmp = (fnum1 & FFPExponent_Mask) - 0x41;
58 if ( tmp <= 2 || (tmp == 3 && (fnum1 & FFPMantisse_Mask) < 0x90000000) )
60 Res = SPAdd(Res, ((ULONG)SPDiv(Res, one) | FFPSign_Mask ));
63 /* Res = Res / 2 */
65 /* should be (char(Res))-- , but gcc on Linux screws up the result! */
67 tmp = Res & 0xFFFFFF00;
68 Res -= sizeof(char);
69 Res = Res | tmp;
71 if ( 0 == Res || (char)Res < 0 )
73 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
74 return 0;
77 /* if the argument was negative, the result is also negative */
78 if ((char)fnum1 < 0 )
80 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
81 return (Res | FFPSign_Mask);
84 return Res;
86 AROS_LIBFUNC_EXIT