include/muimaster/macros.h: get() compiler delint
[AROS.git] / workbench / libs / mathtrans / sptanh.c
blobaf885455e5527aca4cb395b98d9aa886c74145a9
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, SPTanh,
14 /* SYNOPSIS */
15 AROS_LHA(float, fnum1, D0),
17 /* LOCATION */
18 struct Library *, MathTransBase, 12, MathTrans)
20 /* FUNCTION
21 Calculate hyperbolic tangens 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 : (not possible)
33 BUGS
35 INTERNALS
36 ( e^x - e^(-x) )
37 tanh(x) = ----------------
38 ( e^x + e^(-x) )
40 tanh( |x| > 9 ) = 1
42 *****************************************************************************/
44 AROS_LIBFUNC_INIT
46 ULONG Res;
47 LONG tmp;
49 tmp = (fnum1 & FFPExponent_Mask) - 0x41;
51 if ( tmp >= 3 && (fnum1 & FFPMantisse_Mask) >= 0x90000000 )
53 /*
54 tanh( x > 9 ) = 1
55 tanh( x <-9 ) = -1
56 */
57 return (one | ( fnum1 & FFPSign_Mask ));
60 /* tanh(-x) = -tanh(x) */
61 Res = SPExp(fnum1 & (FFPMantisse_Mask + FFPExponent_Mask ));
62 Res = SPDiv
64 SPAdd(Res, SPDiv(Res, one)),
65 SPAdd(Res, (ULONG)SPDiv(Res, one) | FFPSign_Mask )
68 /* Result is zero */
69 if (0 == Res )
71 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
72 return 0;
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 );
82 return Res;
84 AROS_LIBFUNC_EXIT