1120492Sfjoe/* e_asinf.c -- float version of e_asin.c. 2120492Sfjoe * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3120492Sfjoe */ 4120492Sfjoe 5120492Sfjoe/* 6120492Sfjoe * ==================================================== 7120492Sfjoe * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8120492Sfjoe * 9120492Sfjoe * Developed at SunPro, a Sun Microsystems, Inc. business. 10120492Sfjoe * Permission to use, copy, modify, and distribute this 11120492Sfjoe * software is freely granted, provided that this notice 12120492Sfjoe * is preserved. 13120492Sfjoe * ==================================================== 14120492Sfjoe */ 15120492Sfjoe 16120492Sfjoe#include <sys/cdefs.h> 17120492Sfjoe__FBSDID("$FreeBSD$"); 18120492Sfjoe 19120492Sfjoe#include "math.h" 20120492Sfjoe#include "math_private.h" 21120492Sfjoe 22120492Sfjoestatic const float 23120492Sfjoeone = 1.0000000000e+00, /* 0x3F800000 */ 24120492Sfjoehuge = 1.000e+30, 25120492Sfjoe /* coefficient for R(x^2) */ 26120492SfjoepS0 = 1.6666586697e-01, 27120492SfjoepS1 = -4.2743422091e-02, 28120492SfjoepS2 = -8.6563630030e-03, 29120492SfjoeqS1 = -7.0662963390e-01; 30120492Sfjoe 31120492Sfjoestatic const double 32120492Sfjoepio2 = 1.570796326794896558e+00; 33120492Sfjoe 34120492Sfjoefloat 35120492Sfjoe__ieee754_asinf(float x) 36120492Sfjoe{ 37120492Sfjoe double s; 38120492Sfjoe float t,w,p,q; 39120492Sfjoe int32_t hx,ix; 40120492Sfjoe GET_FLOAT_WORD(hx,x); 41120492Sfjoe ix = hx&0x7fffffff; 42120492Sfjoe if(ix>=0x3f800000) { /* |x| >= 1 */ 43120492Sfjoe if(ix==0x3f800000) /* |x| == 1 */ 44120492Sfjoe return x*pio2; /* asin(+-1) = +-pi/2 with inexact */ 45120492Sfjoe return (x-x)/(x-x); /* asin(|x|>1) is NaN */ 46120492Sfjoe } else if (ix<0x3f000000) { /* |x|<0.5 */ 47120492Sfjoe if(ix<0x39800000) { /* |x| < 2**-12 */ 48120492Sfjoe if(huge+x>one) return x;/* return x with inexact if x!=0*/ 49120492Sfjoe } 50120492Sfjoe t = x*x; 51120492Sfjoe p = t*(pS0+t*(pS1+t*pS2)); 52120492Sfjoe q = one+t*qS1; 53120492Sfjoe w = p/q; 54120492Sfjoe return x+x*w; 55120492Sfjoe } 56120492Sfjoe /* 1> |x|>= 0.5 */ 57120492Sfjoe w = one-fabsf(x); 58120492Sfjoe t = w*(float)0.5; 59120492Sfjoe p = t*(pS0+t*(pS1+t*pS2)); 60120492Sfjoe q = one+t*qS1; 61120492Sfjoe s = sqrt(t); 62120492Sfjoe w = p/q; 63120492Sfjoe t = pio2-2.0*(s+s*w); 64120492Sfjoe if(hx>0) return t; else return -t; 65120492Sfjoe} 66120492Sfjoe