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 sine 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
41 AROS_LHQUAD1(double, IEEEDPAsin
,
42 AROS_LHAQUAD(double, x
, D0
, D1
),
43 struct MathIeeeDoubTransBase
*, MathIeeeDoubTransBase
, 19, MathIeeeDoubTrans
52 if this is a 32bit -compiler we need to define some variables, otherwise
53 these are available as 64bit constants
55 # if defined AROS_64BIT_TYPE || defined __GNUC__
60 const QUAD two_64
= two
,
65 hx
= Get_High32of64(x
);
69 if(( (ix
-0x3ff00000) | Get_Low32of64(x
) ) == 0)
70 { /* |x|==1 -> asin(1) = pi/2 */
72 if this is a 32bit -compiler we need to define some variables, otherwise
73 these are available as 64bit constants
77 # if defined AROS_64BIT_TYPE || defined __GNUC__
80 QUAD pio2_hi_64
= pio2_hi
;
87 # if defined AROS_64BIT_TYPE || defined __GNUC__
89 # undef neg_pio2_hi_64
90 QUAD neg_pio2_hi_64
= neg_pio2_hi
;
93 return neg_pio2_hi_64
;
96 else /* asin(>1) = NAN */
99 if this is a 32bit -compiler we need to define some variables,
100 otherwise these are available as 64bit constants
102 # if defined AROS_64BIT_TYPE || defined __GNUC__
106 Set_Value64C(IEEEDPNAN_64
, IEEEDPNAN_Hi
, IEEEDPNAN_Lo
);
109 return IEEEDPNAN_64
; /* acos(>1)= NAN */
115 if this is a 32bit -compiler we need to define some variables,
116 otherwise these are available as 64bit constants
119 # 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
<= 0x3e400000) return x
;/* if|x|<2**-27 -> asin(x)=x */
152 Set_Value64(t
, IEEEDPMul(x
, x
));
156 IEEEDPMul(t
, IEEEDPAdd(pS0_64
,
157 IEEEDPMul(t
, IEEEDPAdd(pS1_64
,
158 IEEEDPMul(t
, IEEEDPAdd(pS2_64
,
159 IEEEDPMul(t
, IEEEDPAdd(pS3_64
,
160 IEEEDPMul(t
, IEEEDPAdd(pS4_64
,
161 IEEEDPMul(t
, pS5_64
)))))))))))
168 IEEEDPMul(t
, IEEEDPAdd(qS1_64
,
169 IEEEDPMul(t
, IEEEDPAdd(qS2_64
,
170 IEEEDPMul(t
, IEEEDPAdd(qS3_64
,
171 IEEEDPMul(t
, qS4_64
))))))))
173 Set_Value64(w
, IEEEDPDiv(p
, q
));
174 Set_Value64(t
, IEEEDPAdd(x
, IEEEDPMul(x
, w
)));
180 if this is a 32bit -compiler we need to define some variables,
181 otherwise these are available as 64bit constants
183 # if defined AROS_64BIT_TYPE || defined __GNUC__
191 const QUAD one_64
= oneC
,
192 onehalf_64
= onehalf
,
194 pio2_hi_64
= pio2_hi
,
195 pio2_lo_64
= pio2_lo
,
196 pio4_hi_64
= pio4_hi
;
202 (IEEEDPMantisse_Mask_Hi
| IEEEDPExponent_Mask_Hi
),
203 (IEEEDPMantisse_Mask_Lo
| IEEEDPExponent_Mask_Lo
)
205 Set_Value64(w
, IEEEDPSub(one_64
, x
));
206 Set_Value64(t
, IEEEDPMul(w
, onehalf_64
));
210 IEEEDPMul(t
, IEEEDPAdd(pS0_64
,
211 IEEEDPMul(t
, IEEEDPAdd(pS1_64
,
212 IEEEDPMul(t
, IEEEDPAdd(pS2_64
,
213 IEEEDPMul(t
, IEEEDPAdd(pS3_64
,
214 IEEEDPMul(t
, IEEEDPAdd(pS4_64
,
215 IEEEDPMul(t
, pS5_64
)))))))))))
222 IEEEDPMul(t
, IEEEDPAdd(qS1_64
,
223 IEEEDPMul(t
, IEEEDPAdd(qS2_64
,
224 IEEEDPMul(t
, IEEEDPAdd(qS3_64
,
225 IEEEDPMul(t
, qS4_64
))))))))
227 Set_Value64(s
, IEEEDPSqrt(t
));
229 if(ix
>= 0x3fef3333) /* if |x| > 0.975 */
231 Set_Value64(w
, IEEEDPDiv(p
,q
));
237 pio2_hi_64
, IEEEDPSub
254 AND64QC(w
,0xffffffff,0x0);
257 c
, IEEEDPDiv(IEEEDPSub(t
, IEEEDPMul(w
, w
)), IEEEDPAdd(s
,w
))
259 Set_Value64(r
, IEEEDPDiv(p
,q
));
265 IEEEDPMul(IEEEDPMul(two_64
, s
), r
),
266 IEEEDPSub(pio2_lo_64
, IEEEDPMul(two_64
, c
))
269 Set_Value64(q
, IEEEDPSub(pio4_hi_64
,IEEEDPMul(two_64
,w
)));
270 Set_Value64(t
, IEEEDPSub(pio4_hi_64
,IEEEDPSub(p
,q
)));
278 OR64QC(t
, IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
);