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, IEEEDPAsin
,
25 AROS_LHAQUAD(double, x
, D0
, D1
),
28 struct MathIeeeDoubTransBase
*, MathIeeeDoubTransBase
, 19, MathIeeeDoubTrans
)
31 Calculate the arcus sine 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 *****************************************************************************/
55 if this is a 32bit -compiler we need to define some variables, otherwise
56 these are available as 64bit constants
58 # if defined AROS_64BIT_TYPE || defined __GNUC__
63 const QUAD two_64
= two
,
68 hx
= Get_High32of64(x
);
72 if(( (ix
-0x3ff00000) | Get_Low32of64(x
) ) == 0)
73 { /* |x|==1 -> asin(1) = pi/2 */
75 if this is a 32bit -compiler we need to define some variables, otherwise
76 these are available as 64bit constants
80 # if defined AROS_64BIT_TYPE || defined __GNUC__
83 QUAD pio2_hi_64
= pio2_hi
;
90 # if defined AROS_64BIT_TYPE || defined __GNUC__
92 # undef neg_pio2_hi_64
93 QUAD neg_pio2_hi_64
= neg_pio2_hi
;
96 return neg_pio2_hi_64
;
99 else /* asin(>1) = NAN */
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(>1)= NAN */
118 if this is a 32bit -compiler we need to define some variables,
119 otherwise these are available as 64bit constants
122 # if defined AROS_64BIT_TYPE || defined __GNUC__
137 /* Ok, let's define some constants */
138 const QUAD pS0_64
= pS0
,
144 const QUAD qS1_64
= qS1
,
148 const QUAD pio2_hi_64
= pio2_hi
;
153 if(ix
<= 0x3e400000) return x
;/* if|x|<2**-27 -> asin(x)=x */
155 Set_Value64(t
, IEEEDPMul(x
, x
));
159 IEEEDPMul(t
, IEEEDPAdd(pS0_64
,
160 IEEEDPMul(t
, IEEEDPAdd(pS1_64
,
161 IEEEDPMul(t
, IEEEDPAdd(pS2_64
,
162 IEEEDPMul(t
, IEEEDPAdd(pS3_64
,
163 IEEEDPMul(t
, IEEEDPAdd(pS4_64
,
164 IEEEDPMul(t
, pS5_64
)))))))))))
171 IEEEDPMul(t
, IEEEDPAdd(qS1_64
,
172 IEEEDPMul(t
, IEEEDPAdd(qS2_64
,
173 IEEEDPMul(t
, IEEEDPAdd(qS3_64
,
174 IEEEDPMul(t
, qS4_64
))))))))
176 Set_Value64(w
, IEEEDPDiv(p
, q
));
177 Set_Value64(t
, IEEEDPAdd(x
, IEEEDPMul(x
, w
)));
183 if this is a 32bit -compiler we need to define some variables,
184 otherwise these are available as 64bit constants
186 # if defined AROS_64BIT_TYPE || defined __GNUC__
194 const QUAD one_64
= oneC
,
195 onehalf_64
= onehalf
,
197 pio2_hi_64
= pio2_hi
,
198 pio2_lo_64
= pio2_lo
,
199 pio4_hi_64
= pio4_hi
;
205 (IEEEDPMantisse_Mask_Hi
| IEEEDPExponent_Mask_Hi
),
206 (IEEEDPMantisse_Mask_Lo
| IEEEDPExponent_Mask_Lo
)
208 Set_Value64(w
, IEEEDPSub(one_64
, x
));
209 Set_Value64(t
, IEEEDPMul(w
, onehalf_64
));
213 IEEEDPMul(t
, IEEEDPAdd(pS0_64
,
214 IEEEDPMul(t
, IEEEDPAdd(pS1_64
,
215 IEEEDPMul(t
, IEEEDPAdd(pS2_64
,
216 IEEEDPMul(t
, IEEEDPAdd(pS3_64
,
217 IEEEDPMul(t
, IEEEDPAdd(pS4_64
,
218 IEEEDPMul(t
, pS5_64
)))))))))))
225 IEEEDPMul(t
, IEEEDPAdd(qS1_64
,
226 IEEEDPMul(t
, IEEEDPAdd(qS2_64
,
227 IEEEDPMul(t
, IEEEDPAdd(qS3_64
,
228 IEEEDPMul(t
, qS4_64
))))))))
230 Set_Value64(s
, IEEEDPSqrt(t
));
232 if(ix
>= 0x3fef3333) /* if |x| > 0.975 */
234 Set_Value64(w
, IEEEDPDiv(p
,q
));
240 pio2_hi_64
, IEEEDPSub
257 AND64QC(w
,0xffffffff,0x0);
260 c
, IEEEDPDiv(IEEEDPSub(t
, IEEEDPMul(w
, w
)), IEEEDPAdd(s
,w
))
262 Set_Value64(r
, IEEEDPDiv(p
,q
));
268 IEEEDPMul(IEEEDPMul(two_64
, s
), r
),
269 IEEEDPSub(pio2_lo_64
, IEEEDPMul(two_64
, c
))
272 Set_Value64(q
, IEEEDPSub(pio4_hi_64
,IEEEDPMul(two_64
,w
)));
273 Set_Value64(t
, IEEEDPSub(pio4_hi_64
,IEEEDPSub(p
,q
)));
281 OR64QC(t
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
);