2 /* FreeBSD: head/lib/msun/src/e_asin.c 176451 2008-02-22 02:30:36Z das */
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 * Developed at SunSoft, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
11 * ====================================================
15 * See comments in e_asin.c.
16 * Converted to long double by David Schultz <das@FreeBSD.ORG>.
23 #include "math_private.h"
25 static const long double
26 one = 1.00000000000000000000e+00,
33 long double t=0.0,w,p,q,c,r,s;
34 int16_t expsign, expt;
36 expsign = u.xbits.expsign;
37 expt = expsign & 0x7fff;
38 if(expt >= BIAS) { /* |x|>= 1 */
39 if(expt==BIAS && ((u.bits.manh&~LDBL_NBIT)|u.bits.manl)==0)
40 /* asin(1)=+-pi/2 with inexact */
41 return x*pio2_hi+x*pio2_lo;
42 return (x-x)/(x-x); /* asin(|x|>1) is NaN */
43 } else if (expt<BIAS-1) { /* |x|<0.5 */
44 if(expt<ASIN_LINEAR) { /* if |x| is small, asinl(x)=x */
45 if(huge+x>one) return x;/* return x with inexact if x!=0*/
59 if(u.bits.manh>=THRESH) { /* if |x| is close to 1 */
61 t = pio2_hi-(2.0*(s+s*w)-pio2_lo);
68 p = 2.0*s*r-(pio2_lo-2.0*c);
72 if(expsign>0) return t; else return -t;