2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
6 #include "mathieeesingtrans_intern.h"
8 /*****************************************************************************
12 AROS_LH1(float, IEEESPAtan
,
15 AROS_LHA(float, y
, D0
),
18 struct Library
*, MathIeeeSingTransBase
, 5, MathIeeeSingTrans
)
21 Calculates the angle of a given number representing the tangent
22 of that angle. The angle will be in radians.
27 IEEE single precision floating point number
33 *****************************************************************************/
37 LONG yabs
= y
& (IEEESPMantisse_Mask
| IEEESPExponent_Mask
);
38 LONG ysquared
, ycubed
;
40 /* check for +- infinity -> output: +-pi/2 */
41 if (IEEESP_Pinfty
== yabs
) return (pio2
| (y
& IEEESPSign_Mask
));
46 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
50 /* atan(x >= 128) = pi/2 - 1/x */
51 if ( (yabs
& IEEESPExponent_Mask
) >= 0x43000000)
53 if (yabs
== y
) /* arg has ppositive sign */
55 SetSR(0, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
56 return IEEESPSub(pio2
,IEEESPDiv(one
,yabs
));
60 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
61 return (IEEESPSub(pio2
,IEEESPDiv(one
,yabs
))) | IEEESPSign_Mask
;
65 /* atan(x >= 64) = pi/2 - 1/x +1/(3*x^3) */
67 ysquared
= IEEESPMul(yabs
, yabs
);
69 if( (yabs
& IEEESPExponent_Mask
) >= 0x42000000)
71 ycubed
= IEEESPMul(yabs
, ysquared
);
73 /* pi/2 - 1/x + 1/(3*x^3) = pi/2 + (1-3*x^2)/(3*x^3)*/
74 if (yabs
== y
) /* arg has positive sign */
76 SetSR(0, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
83 IEEESPMul(three
, ysquared
) | IEEESPSign_Mask
, one
85 IEEESPMul(three
, ycubed
)
91 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
98 IEEESPMul(three
, ysquared
) | IEEESPSign_Mask
, one
100 IEEESPMul(three
, ycubed
)
107 return IEEESPAsin(IEEESPDiv(y
,IEEESPSqrt(IEEESPAdd(one
,ysquared
))));