12116Sjkh/* e_asinf.c -- float version of e_asin.c. 22116Sjkh * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 32116Sjkh */ 42116Sjkh 52116Sjkh/* 62116Sjkh * ==================================================== 72116Sjkh * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 82116Sjkh * 92116Sjkh * Developed at SunPro, a Sun Microsystems, Inc. business. 102116Sjkh * Permission to use, copy, modify, and distribute this 118870Srgrimes * software is freely granted, provided that this notice 122116Sjkh * is preserved. 132116Sjkh * ==================================================== 142116Sjkh */ 152116Sjkh 16176451Sdas#include <sys/cdefs.h> 17176451Sdas__FBSDID("$FreeBSD$"); 182116Sjkh 192116Sjkh#include "math.h" 202116Sjkh#include "math_private.h" 212116Sjkh 228870Srgrimesstatic const float 232116Sjkhone = 1.0000000000e+00, /* 0x3F800000 */ 242116Sjkhhuge = 1.000e+30, 252116Sjkh /* coefficient for R(x^2) */ 26181100SdaspS0 = 1.6666586697e-01, 27181100SdaspS1 = -4.2743422091e-02, 28181100SdaspS2 = -8.6563630030e-03, 29181100SdasqS1 = -7.0662963390e-01; 302116Sjkh 31181100Sdasstatic const double 32181100Sdaspio2 = 1.570796326794896558e+00; 33181100Sdas 3497407Salfredfloat 3597407Salfred__ieee754_asinf(float x) 362116Sjkh{ 37181100Sdas double s; 38181405Sdas float t,w,p,q; 392116Sjkh int32_t hx,ix; 402116Sjkh GET_FLOAT_WORD(hx,x); 412116Sjkh ix = hx&0x7fffffff; 42181257Sdas if(ix>=0x3f800000) { /* |x| >= 1 */ 43181257Sdas if(ix==0x3f800000) /* |x| == 1 */ 44181257Sdas return x*pio2; /* asin(+-1) = +-pi/2 with inexact */ 458870Srgrimes return (x-x)/(x-x); /* asin(|x|>1) is NaN */ 462116Sjkh } else if (ix<0x3f000000) { /* |x|<0.5 */ 47181257Sdas if(ix<0x39800000) { /* |x| < 2**-12 */ 482116Sjkh if(huge+x>one) return x;/* return x with inexact if x!=0*/ 49181257Sdas } 50181257Sdas t = x*x; 51181257Sdas p = t*(pS0+t*(pS1+t*pS2)); 52181257Sdas q = one+t*qS1; 53181257Sdas w = p/q; 54181257Sdas return x+x*w; 552116Sjkh } 562116Sjkh /* 1> |x|>= 0.5 */ 572116Sjkh w = one-fabsf(x); 582116Sjkh t = w*(float)0.5; 59181100Sdas p = t*(pS0+t*(pS1+t*pS2)); 60181100Sdas q = one+t*qS1; 61181257Sdas s = sqrt(t); 62181100Sdas w = p/q; 63181100Sdas t = pio2-2.0*(s+s*w); 648870Srgrimes if(hx>0) return t; else return -t; 652116Sjkh} 66