2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
6 #include "mathtrans_intern.h"
8 /*****************************************************************************
12 AROS_LH1(float, SPTanh
,
15 AROS_LHA(float, fnum1
, D0
),
18 struct Library
*, MathTransBase
, 12, MathTrans
)
21 Calculate hyperbolic tangens of the ffp number
26 Motorola fast floating point number
30 negative : result is negative
31 overflow : (not possible)
37 tanh(x) = ----------------
42 *****************************************************************************/
49 tmp
= (fnum1
& FFPExponent_Mask
) - 0x41;
51 if ( tmp
>= 3 && (fnum1
& FFPMantisse_Mask
) >= 0x90000000 )
57 return (one
| ( fnum1
& FFPSign_Mask
));
60 /* tanh(-x) = -tanh(x) */
61 Res
= SPExp(fnum1
& (FFPMantisse_Mask
+ FFPExponent_Mask
));
64 SPAdd(Res
, SPDiv(Res
, one
)),
65 SPAdd(Res
, (ULONG
)SPDiv(Res
, one
) | FFPSign_Mask
)
71 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
75 /* Argument is negative -> result is negative */
76 if ( (char) fnum1
< 0)
78 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
79 return (Res
| FFPSign_Mask
);