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"
19 /*****************************************************************************
23 AROS_LH1(float, SPAcos
,
26 AROS_LHA(float, fnum1
, D0
),
29 struct Library
*, MathTransBase
, 20, MathTrans
)
32 Calculate arcuscos of the given number
37 Motorola fast floating point number
41 negative : 0 (not possible)
42 overflow : fnum < -1 or fnum > 1
50 *****************************************************************************/
55 LONG z
,p
,q
,r
,w
,s
,c
,ix
,df
;
56 ix
= fnum1
& (FFPMantisse_Mask
| FFPExponent_Mask
); /* ix = |fnum| */
60 if (1==z
) /* |fnum1| > 1 */
62 SetSR(Overflow_Bit
, Zero_Bit
| Overflow_Bit
| Negative_Bit
);
66 if (0==z
) /* |fnum1| = 1 */
68 if (fnum1
& FFPSign_Mask
) /* |fnum| = -1 */ return pi
;
69 SetSR(Zero_Bit
, Zero_Bit
| Overflow_Bit
| Negative_Bit
);
73 /* error: 1 ulp (unit in the last place) */
74 if (-1 == SPCmp(ix
,onehalf
)) /* |fnum1| < 0.5 */
76 z
= SPMul(fnum1
, fnum1
);
77 p
= SPMul(z
, SPAdd(pS0
,
82 SPMul(z
, pS5
)))))))))));
89 return (SPSub(SPAdd(fnum1
,SPMul(fnum1
,r
)),pio2
));
93 if (fnum1
& FFPSign_Mask
) /* fnum1 < -0.5 */
95 z
= SPMul(onehalf
, SPAdd(one
, fnum1
));
96 p
= SPMul(z
, SPAdd(pS0
,
101 SPMul(z
, pS5
)))))))))));
106 SPMul(z
, qS4
))))))));
108 r
= SPDiv(q
,p
); /* r = p/q; */
110 return SPSub(SPMul(two
, SPAdd(s
, w
)) ,pi
);
113 /* error: 8 ulp (this is bad !!!!) */
115 z
= SPMul(onehalf
, SPSub(fnum1
, one
));
118 df
= df
& 0xfff000ff;
119 c
= SPDiv(SPAdd(df
,s
), SPSub( SPMul(df
,df
), z
));
120 p
= SPMul(z
, SPAdd(pS0
,
125 SPMul(z
, pS5
)))))))))));
130 SPMul(z
, qS4
))))))));
132 w
= SPAdd(c
, SPMul(r
,s
));
134 return SPAdd(SPMul(two
, SPAdd(df
,w
)),0x800000a9);