2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 * Developed at SunSoft, a Sun Microsystems, Inc. business.
10 * Permission to use, copy, modify, and distribute this
11 * software is freely granted, provided that this notice
13 * ====================================================
16 #include "mathieeedoubtrans_intern.h"
20 Calculate the arcus cosine of the IEEE double precision number
23 IEEE double precision floating point number
27 negative : result is negative
28 overflow : argument is out of range
43 AROS_LHQUAD1(double, IEEEDPAcos
,
44 AROS_LHAQUAD(double, x
, D0
, D1
),
45 struct MathIeeeDoubTransBase
*, MathIeeeDoubTransBase
, 20, MathIeeeDoubTrans
50 QUAD z
,p
,q
,r
,w
,s
,c
,df
, tmp
;
53 # if defined AROS_64BIT_TYPE || defined __GNUC__
58 const QUAD two_64
= two
,
63 hx
= Get_High32of64(x
);
67 if (((ix
-0x3ff00000) | Get_Low32of64(x
)) == 0)
72 if this is a 32bit-compiler we need to define some
73 variables, otherwise these are available as 64bit
76 # if defined AROS_64BIT_TYPE || defined __GNUC__
87 if this is a 32bit-compiler we need to define some
88 variables, otherwise these are available as 64bit constants
90 # if defined AROS_64BIT_TYPE || defined __GNUC__
96 return pi_64
; /* acos(-1)= pi */
101 if this is a 32bit -compiler we need to define some variables,
102 otherwise these are available as 64bit constants
104 # if defined AROS_64BIT_TYPE || defined __GNUC__
108 Set_Value64C(IEEEDPNAN_64
, IEEEDPNAN_Hi
, IEEEDPNAN_Lo
);
111 return IEEEDPNAN_64
; /* acos(|x|>1) is NaN */
116 if this is a 32bit -compiler we need to define some variables,
117 otherwise these are available as 64bit constants
119 # if defined AROS_64BIT_TYPE || defined __GNUC__
133 /* Ok, let's define some constants */
134 const QUAD pS0_64
= pS0
,
140 const QUAD qS1_64
= qS1
,
144 const QUAD pio2_hi_64
= pio2_hi
;
149 if(ix
<= 0x3c600000) return pio2_hi_64
;/*if|x|<2**-57*/
151 Set_Value64(z
, IEEEDPMul(x
, x
));
155 IEEEDPMul(z
, IEEEDPAdd(pS0_64
,
156 IEEEDPMul(z
, IEEEDPAdd(pS1_64
,
157 IEEEDPMul(z
, IEEEDPAdd(pS2_64
,
158 IEEEDPMul(z
, IEEEDPAdd(pS3_64
,
159 IEEEDPMul(z
, IEEEDPAdd(pS4_64
,
160 IEEEDPMul(z
, pS5_64
)))))))))))
167 IEEEDPMul(z
, IEEEDPAdd(qS1_64
,
168 IEEEDPMul(z
, IEEEDPAdd(qS2_64
,
169 IEEEDPMul(z
, IEEEDPAdd(qS3_64
,
170 IEEEDPMul(z
, qS4_64
))))))))
172 Set_Value64(r
, IEEEDPDiv(p
, q
));
177 IEEEDPSub(pio2_hi_64
,
179 IEEEDPSub(pio2_lo_64
, IEEEDPMul(x
, r
))))
186 if this is a 32bit -compiler we need to define some variables,
187 otherwise these are available as 64bit constants
189 # if defined AROS_64BIT_TYPE || defined __GNUC__
192 const QUAD onehalf_64
= onehalf
;
198 if this is a 32bit-compiler we need to define some
199 variables, otherwise these are available as 64bit constants
201 # if defined AROS_64BIT_TYPE || defined __GNUC__
204 const QUAD pi_64
= pi
;
207 Set_Value64(z
, IEEEDPMul(IEEEDPAdd(one_64
,x
),onehalf_64
));
208 Set_Value64(p
, IEEEDPMul(z
, IEEEDPAdd(pS0_64
,
209 IEEEDPMul(z
, IEEEDPAdd(pS1_64
,
210 IEEEDPMul(z
, IEEEDPAdd(pS2_64
,
211 IEEEDPMul(z
, IEEEDPAdd(pS3_64
,
212 IEEEDPMul(z
, IEEEDPAdd(pS4_64
,
213 IEEEDPMul(z
, pS5_64
))))))))))));
214 Set_Value64(q
, IEEEDPAdd(one_64
,
215 IEEEDPMul(z
, IEEEDPAdd(qS1_64
,
216 IEEEDPMul(z
, IEEEDPAdd(qS2_64
,
217 IEEEDPMul(z
, IEEEDPAdd(qS3_64
,
218 IEEEDPMul(z
,qS4_64
)))))))));
219 Set_Value64(s
, IEEEDPSqrt(z
));
220 Set_Value64(r
, IEEEDPDiv(p
,q
));
221 Set_Value64(w
, IEEEDPSub(IEEEDPMul(r
,s
),pio2_lo_64
));
222 return IEEEDPSub(pi_64
, IEEEDPMul(two_64
, IEEEDPAdd(s
,w
)));
226 Set_Value64(z
, IEEEDPMul(IEEEDPSub(one_64
,x
),onehalf_64
));
227 Set_Value64(s
, IEEEDPSqrt(z
));
229 AND64QC(df
,0xffffffff, 0x0);
230 Set_Value64(c
, IEEEDPDiv(IEEEDPSub(z
,IEEEDPMul(df
,df
)),IEEEDPAdd(s
,df
)));
231 Set_Value64(p
, IEEEDPMul(z
, IEEEDPAdd(pS0_64
,
232 IEEEDPMul(z
, IEEEDPAdd(pS1_64
,
233 IEEEDPMul(z
, IEEEDPAdd(pS2_64
,
234 IEEEDPMul(z
, IEEEDPAdd(pS3_64
,
235 IEEEDPMul(z
, IEEEDPAdd(pS4_64
,
236 IEEEDPMul(z
,pS5_64
))))))))))));
237 Set_Value64(q
, IEEEDPAdd(one_64
,
238 IEEEDPMul(z
, IEEEDPAdd(qS1_64
,
239 IEEEDPMul(z
, IEEEDPAdd(qS2_64
,
240 IEEEDPMul(z
, IEEEDPAdd(qS3_64
,
241 IEEEDPMul(z
,qS4_64
)))))))));
242 Set_Value64(r
, IEEEDPDiv(p
,q
));
243 Set_Value64(w
, IEEEDPAdd(IEEEDPMul(r
,s
),c
));
244 return IEEEDPMul(two_64
,IEEEDPAdd(df
,w
));