Added the functionlist section to the .conf of the libraries present in
[AROS.git] / workbench / libs / mathieeesingtrans / ieeesptan.c
blobd38a57a919dc4539d3a7382b947a06240231db78
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathieeesingtrans_intern.h"
8 /*
9 FUNCTION
10 Calculate the tangens of a given IEEE single precision number in radians
12 RESULT
13 IEEE single precision floating point number
15 flags:
16 zero : result is zero
17 negative : result is negative
18 overflow :
20 NOTES
22 EXAMPLE
24 BUGS
26 SEE ALSO
28 INTERNALS
30 HISTORY
33 AROS_LH1(float, IEEESPTan,
34 AROS_LHA(float, y, D0),
35 struct Library *, MathIeeeSingTransBase, 8, MathIeeeSingTrans
38 AROS_LIBFUNC_INIT
40 LONG z,SIN,Res,ysquared,yabs,tmp;
41 yabs = y & (IEEESPMantisse_Mask + IEEESPExponent_Mask);
43 if (IEEESP_Pinfty == yabs)
45 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
46 return IEEESP_NAN;
49 z = IEEESPFloor(IEEESPDiv(yabs, pi));
50 tmp = IEEESPMul(z,pi);
51 tmp |= IEEESPSign_Mask; /* tmp = -tmp; */
52 yabs = IEEESPAdd(yabs, tmp);
53 if (yabs > pio2)
55 yabs |= IEEESPSign_Mask;
56 yabs =IEEESPAdd(pi, yabs);
57 tmp = TRUE;
59 else
61 tmp = FALSE;
64 ysquared = IEEESPMul(yabs,yabs);
65 SIN = IEEESPMul(yabs,
66 IEEESPAdd(sinf1,
67 IEEESPMul(ysquared,
68 IEEESPAdd(sinf2,
69 IEEESPMul(ysquared,
70 IEEESPAdd(sinf3,
71 IEEESPMul(ysquared,
72 IEEESPAdd(sinf4,
73 IEEESPMul(ysquared,
74 IEEESPAdd(sinf5,
75 IEEESPMul(ysquared, sinf6)))))))))));
76 /* cos: */
77 z = IEEESPAdd(cosf1,
78 IEEESPMul(ysquared,
79 IEEESPAdd(cosf2,
80 IEEESPMul(ysquared,
81 IEEESPAdd(cosf3,
82 IEEESPMul(ysquared,
83 IEEESPAdd(cosf4,
84 IEEESPMul(ysquared,
85 IEEESPAdd(cosf5,
86 IEEESPMul(ysquared, cosf6))))))))));
88 Res = IEEESPDiv(SIN, z);
90 if (y < 0 ) Res ^= IEEESPSign_Mask;
91 if (TRUE == tmp) Res ^= IEEESPSign_Mask;
93 if (0 == Res)
95 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
96 return 0;
99 if (Res < 0) SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
101 return Res;
103 AROS_LIBFUNC_EXIT