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"
18 /*****************************************************************************
22 AROS_LHQUAD1(double, IEEEDPAcos
,
25 AROS_LHAQUAD(double, x
, D0
, D1
),
28 struct MathIeeeDoubTransBase
*, MathIeeeDoubTransBase
, 20, MathIeeeDoubTrans
)
31 Calculate the arcus cosine of the IEEE double precision number
36 IEEE double precision floating point number
40 negative : result is negative
41 overflow : argument is out of range
47 *****************************************************************************/
51 QUAD z
,p
,q
,r
,w
,s
,c
,df
, tmp
;
54 # if defined AROS_64BIT_TYPE || defined __GNUC__
59 const QUAD two_64
= two
,
64 hx
= Get_High32of64(x
);
68 if (((ix
-0x3ff00000) | Get_Low32of64(x
)) == 0)
73 if this is a 32bit-compiler we need to define some
74 variables, otherwise these are available as 64bit
77 # if defined AROS_64BIT_TYPE || defined __GNUC__
88 if this is a 32bit-compiler we need to define some
89 variables, otherwise these are available as 64bit constants
91 # if defined AROS_64BIT_TYPE || defined __GNUC__
97 return pi_64
; /* acos(-1)= pi */
102 if this is a 32bit -compiler we need to define some variables,
103 otherwise these are available as 64bit constants
105 # if defined AROS_64BIT_TYPE || defined __GNUC__
109 Set_Value64C(IEEEDPNAN_64
, IEEEDPNAN_Hi
, IEEEDPNAN_Lo
);
112 return IEEEDPNAN_64
; /* acos(|x|>1) is NaN */
117 if this is a 32bit -compiler we need to define some variables,
118 otherwise these are available as 64bit constants
120 # if defined AROS_64BIT_TYPE || defined __GNUC__
134 /* Ok, let's define some constants */
135 const QUAD pS0_64
= pS0
,
141 const QUAD qS1_64
= qS1
,
145 const QUAD pio2_hi_64
= pio2_hi
;
150 if(ix
<= 0x3c600000) return pio2_hi_64
;/*if|x|<2**-57*/
152 Set_Value64(z
, IEEEDPMul(x
, x
));
156 IEEEDPMul(z
, IEEEDPAdd(pS0_64
,
157 IEEEDPMul(z
, IEEEDPAdd(pS1_64
,
158 IEEEDPMul(z
, IEEEDPAdd(pS2_64
,
159 IEEEDPMul(z
, IEEEDPAdd(pS3_64
,
160 IEEEDPMul(z
, IEEEDPAdd(pS4_64
,
161 IEEEDPMul(z
, pS5_64
)))))))))))
168 IEEEDPMul(z
, IEEEDPAdd(qS1_64
,
169 IEEEDPMul(z
, IEEEDPAdd(qS2_64
,
170 IEEEDPMul(z
, IEEEDPAdd(qS3_64
,
171 IEEEDPMul(z
, qS4_64
))))))))
173 Set_Value64(r
, IEEEDPDiv(p
, q
));
178 IEEEDPSub(pio2_hi_64
,
180 IEEEDPSub(pio2_lo_64
, IEEEDPMul(x
, r
))))
187 if this is a 32bit -compiler we need to define some variables,
188 otherwise these are available as 64bit constants
190 # if defined AROS_64BIT_TYPE || defined __GNUC__
193 const QUAD onehalf_64
= onehalf
;
199 if this is a 32bit-compiler we need to define some
200 variables, otherwise these are available as 64bit constants
202 # if defined AROS_64BIT_TYPE || defined __GNUC__
205 const QUAD pi_64
= pi
;
208 Set_Value64(z
, IEEEDPMul(IEEEDPAdd(one_64
,x
),onehalf_64
));
209 Set_Value64(p
, IEEEDPMul(z
, IEEEDPAdd(pS0_64
,
210 IEEEDPMul(z
, IEEEDPAdd(pS1_64
,
211 IEEEDPMul(z
, IEEEDPAdd(pS2_64
,
212 IEEEDPMul(z
, IEEEDPAdd(pS3_64
,
213 IEEEDPMul(z
, IEEEDPAdd(pS4_64
,
214 IEEEDPMul(z
, pS5_64
))))))))))));
215 Set_Value64(q
, IEEEDPAdd(one_64
,
216 IEEEDPMul(z
, IEEEDPAdd(qS1_64
,
217 IEEEDPMul(z
, IEEEDPAdd(qS2_64
,
218 IEEEDPMul(z
, IEEEDPAdd(qS3_64
,
219 IEEEDPMul(z
,qS4_64
)))))))));
220 Set_Value64(s
, IEEEDPSqrt(z
));
221 Set_Value64(r
, IEEEDPDiv(p
,q
));
222 Set_Value64(w
, IEEEDPSub(IEEEDPMul(r
,s
),pio2_lo_64
));
223 return IEEEDPSub(pi_64
, IEEEDPMul(two_64
, IEEEDPAdd(s
,w
)));
227 Set_Value64(z
, IEEEDPMul(IEEEDPSub(one_64
,x
),onehalf_64
));
228 Set_Value64(s
, IEEEDPSqrt(z
));
230 AND64QC(df
,0xffffffff, 0x0);
231 Set_Value64(c
, IEEEDPDiv(IEEEDPSub(z
,IEEEDPMul(df
,df
)),IEEEDPAdd(s
,df
)));
232 Set_Value64(p
, IEEEDPMul(z
, IEEEDPAdd(pS0_64
,
233 IEEEDPMul(z
, IEEEDPAdd(pS1_64
,
234 IEEEDPMul(z
, IEEEDPAdd(pS2_64
,
235 IEEEDPMul(z
, IEEEDPAdd(pS3_64
,
236 IEEEDPMul(z
, IEEEDPAdd(pS4_64
,
237 IEEEDPMul(z
,pS5_64
))))))))))));
238 Set_Value64(q
, IEEEDPAdd(one_64
,
239 IEEEDPMul(z
, IEEEDPAdd(qS1_64
,
240 IEEEDPMul(z
, IEEEDPAdd(qS2_64
,
241 IEEEDPMul(z
, IEEEDPAdd(qS3_64
,
242 IEEEDPMul(z
,qS4_64
)))))))));
243 Set_Value64(r
, IEEEDPDiv(p
,q
));
244 Set_Value64(w
, IEEEDPAdd(IEEEDPMul(r
,s
),c
));
245 return IEEEDPMul(two_64
,IEEEDPAdd(df
,w
));