2 /* @(#)e_asin.c 1.3 95/01/18 */
3 /* FreeBSD: head/lib/msun/src/e_asin.c 176451 2008-02-22 02:30:36Z das */
5 * ====================================================
6 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8 * Developed at SunSoft, a Sun Microsystems, Inc. business.
9 * Permission to use, copy, modify, and distribute this
10 * software is freely granted, provided that this notice
12 * ====================================================
15 #include <sys/cdefs.h>
16 __FBSDID("$FreeBSD$");
19 * See comments in e_asin.c.
20 * Converted to long double by David Schultz <das@FreeBSD.ORG>.
27 #include "math_private.h"
29 static const long double
30 one
= 1.00000000000000000000e+00,
37 long double t
=0.0,w
,p
,q
,c
,r
,s
;
38 int16_t expsign
, expt
;
40 expsign
= u
.xbits
.expsign
;
41 expt
= expsign
& 0x7fff;
42 if(expt
>= BIAS
) { /* |x|>= 1 */
43 if(expt
==BIAS
&& ((u
.bits
.manh
&~LDBL_NBIT
)|u
.bits
.manl
)==0)
44 /* asin(1)=+-pi/2 with inexact */
45 return x
*pio2_hi
+x
*pio2_lo
;
46 return (x
-x
)/(x
-x
); /* asin(|x|>1) is NaN */
47 } else if (expt
<BIAS
-1) { /* |x|<0.5 */
48 if(expt
<ASIN_LINEAR
) { /* if |x| is small, asinl(x)=x */
49 if(huge
+x
>one
) return x
;/* return x with inexact if x!=0*/
63 if(u
.bits
.manh
>=THRESH
) { /* if |x| is close to 1 */
65 t
= pio2_hi
-(2.0*(s
+s
*w
)-pio2_lo
);
72 p
= 2.0*s
*r
-(pio2_lo
-2.0*c
);
76 if(expsign
>0) return t
; else return -t
;