2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
7 * ====================================================
8 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
10 * Developed at SunSoft, a Sun Microsystems, Inc. business.
11 * Permission to use, copy, modify, and distribute this
12 * software is freely granted, provided that this notice
14 * ====================================================
17 #include "mathtrans_intern.h"
21 Calculate arcuscos of the given number
24 Motorola fast floating point number
28 negative : 0 (not possible)
29 overflow : fnum < -1 or fnum > 1
44 AROS_LH1(float, SPAcos
,
45 AROS_LHA(float, fnum1
, D0
),
46 struct Library
*, MathTransBase
, 20, MathTrans
52 LONG z
,p
,q
,r
,w
,s
,c
,ix
,df
;
53 ix
= fnum1
& (FFPMantisse_Mask
| FFPExponent_Mask
); /* ix = |fnum| */
57 if (1==z
) /* |fnum1| > 1 */
59 SetSR(Overflow_Bit
, Zero_Bit
| Overflow_Bit
| Negative_Bit
);
63 if (0==z
) /* |fnum1| = 1 */
65 if (fnum1
& FFPSign_Mask
) /* |fnum| = -1 */ return pi
;
66 SetSR(Zero_Bit
, Zero_Bit
| Overflow_Bit
| Negative_Bit
);
70 /* error: 1 ulp (unit in the last place) */
71 if (-1 == SPCmp(ix
,onehalf
)) /* |fnum1| < 0.5 */
73 z
= SPMul(fnum1
, fnum1
);
74 p
= SPMul(z
, SPAdd(pS0
,
79 SPMul(z
, pS5
)))))))))));
86 return (SPSub(SPAdd(fnum1
,SPMul(fnum1
,r
)),pio2
));
90 if (fnum1
& FFPSign_Mask
) /* fnum1 < -0.5 */
92 z
= SPMul(onehalf
, SPAdd(one
, fnum1
));
93 p
= SPMul(z
, SPAdd(pS0
,
98 SPMul(z
, pS5
)))))))))));
103 SPMul(z
, qS4
))))))));
105 r
= SPDiv(q
,p
); /* r = p/q; */
107 return SPSub(SPMul(two
, SPAdd(s
, w
)) ,pi
);
110 /* error: 8 ulp (this is bad !!!!) */
112 z
= SPMul(onehalf
, SPSub(fnum1
, one
));
115 df
= df
& 0xfff000ff;
116 c
= SPDiv(SPAdd(df
,s
), SPSub( SPMul(df
,df
), z
));
117 p
= SPMul(z
, SPAdd(pS0
,
122 SPMul(z
, pS5
)))))))))));
127 SPMul(z
, qS4
))))))));
129 w
= SPAdd(c
, SPMul(r
,s
));
131 return SPAdd(SPMul(two
, SPAdd(df
,w
)),0x800000a9);