< prev index next >

src/java.base/share/native/libfdlibm/e_asin.c

Print this page




  81 
  82 #ifdef __STDC__
  83         double __ieee754_asin(double x)
  84 #else
  85         double __ieee754_asin(x)
  86         double x;
  87 #endif
  88 {
  89         double t=0,w,p,q,c,r,s;
  90         int hx,ix;
  91         hx = __HI(x);
  92         ix = hx&0x7fffffff;
  93         if(ix>= 0x3ff00000) {           /* |x|>= 1 */
  94             if(((ix-0x3ff00000)|__LO(x))==0)
  95                     /* asin(1)=+-pi/2 with inexact */
  96                 return x*pio2_hi+x*pio2_lo;
  97             return (x-x)/(x-x);         /* asin(|x|>1) is NaN */
  98         } else if (ix<0x3fe00000) {     /* |x|<0.5 */
  99             if(ix<0x3e400000) {         /* if |x| < 2**-27 */
 100                 if(huge+x>one) return x;/* return x with inexact if x!=0*/
 101             } else
 102                 t = x*x;

 103                 p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
 104                 q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
 105                 w = p/q;
 106                 return x+x*w;
 107         }
 108         /* 1> |x|>= 0.5 */
 109         w = one-fabs(x);
 110         t = w*0.5;
 111         p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
 112         q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
 113         s = sqrt(t);
 114         if(ix>=0x3FEF3333) {    /* if |x| > 0.975 */
 115             w = p/q;
 116             t = pio2_hi-(2.0*(s+s*w)-pio2_lo);
 117         } else {
 118             w  = s;
 119             __LO(w) = 0;
 120             c  = (t-w*w)/(s+w);
 121             r  = p/q;
 122             p  = 2.0*s*r-(pio2_lo-2.0*c);


  81 
  82 #ifdef __STDC__
  83         double __ieee754_asin(double x)
  84 #else
  85         double __ieee754_asin(x)
  86         double x;
  87 #endif
  88 {
  89         double t=0,w,p,q,c,r,s;
  90         int hx,ix;
  91         hx = __HI(x);
  92         ix = hx&0x7fffffff;
  93         if(ix>= 0x3ff00000) {           /* |x|>= 1 */
  94             if(((ix-0x3ff00000)|__LO(x))==0)
  95                     /* asin(1)=+-pi/2 with inexact */
  96                 return x*pio2_hi+x*pio2_lo;
  97             return (x-x)/(x-x);         /* asin(|x|>1) is NaN */
  98         } else if (ix<0x3fe00000) {     /* |x|<0.5 */
  99             if(ix<0x3e400000) {         /* if |x| < 2**-27 */
 100                 if(huge+x>one) return x;/* return x with inexact if x!=0*/
 101             } else {
 102                 t = x*x;
 103             }
 104             p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
 105             q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
 106             w = p/q;
 107             return x+x*w;
 108         }
 109         /* 1> |x|>= 0.5 */
 110         w = one-fabs(x);
 111         t = w*0.5;
 112         p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
 113         q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
 114         s = sqrt(t);
 115         if(ix>=0x3FEF3333) {    /* if |x| > 0.975 */
 116             w = p/q;
 117             t = pio2_hi-(2.0*(s+s*w)-pio2_lo);
 118         } else {
 119             w  = s;
 120             __LO(w) = 0;
 121             c  = (t-w*w)/(s+w);
 122             r  = p/q;
 123             p  = 2.0*s*r-(pio2_lo-2.0*c);
< prev index next >