e_acosf.c revision 97407
12116Sjkh/* e_acosf.c -- float version of e_acos.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 162116Sjkh#ifndef lint 1750476Speterstatic char rcsid[] = "$FreeBSD: head/lib/msun/src/e_acosf.c 97407 2002-05-28 17:03:12Z alfred $"; 182116Sjkh#endif 192116Sjkh 202116Sjkh#include "math.h" 212116Sjkh#include "math_private.h" 222116Sjkh 238870Srgrimesstatic const float 242116Sjkhone = 1.0000000000e+00, /* 0x3F800000 */ 252116Sjkhpi = 3.1415925026e+00, /* 0x40490fda */ 262116Sjkhpio2_hi = 1.5707962513e+00, /* 0x3fc90fda */ 272116Sjkhpio2_lo = 7.5497894159e-08, /* 0x33a22168 */ 282116SjkhpS0 = 1.6666667163e-01, /* 0x3e2aaaab */ 292116SjkhpS1 = -3.2556581497e-01, /* 0xbea6b090 */ 302116SjkhpS2 = 2.0121252537e-01, /* 0x3e4e0aa8 */ 312116SjkhpS3 = -4.0055535734e-02, /* 0xbd241146 */ 322116SjkhpS4 = 7.9153501429e-04, /* 0x3a4f7f04 */ 332116SjkhpS5 = 3.4793309169e-05, /* 0x3811ef08 */ 342116SjkhqS1 = -2.4033949375e+00, /* 0xc019d139 */ 352116SjkhqS2 = 2.0209457874e+00, /* 0x4001572d */ 362116SjkhqS3 = -6.8828397989e-01, /* 0xbf303361 */ 372116SjkhqS4 = 7.7038154006e-02; /* 0x3d9dc62e */ 382116Sjkh 3997407Salfredfloat 4097407Salfred__ieee754_acosf(float x) 412116Sjkh{ 422116Sjkh float z,p,q,r,w,s,c,df; 432116Sjkh int32_t hx,ix; 442116Sjkh GET_FLOAT_WORD(hx,x); 452116Sjkh ix = hx&0x7fffffff; 462116Sjkh if(ix==0x3f800000) { /* |x|==1 */ 472116Sjkh if(hx>0) return 0.0; /* acos(1) = 0 */ 482116Sjkh else return pi+(float)2.0*pio2_lo; /* acos(-1)= pi */ 492116Sjkh } else if(ix>0x3f800000) { /* |x| >= 1 */ 502116Sjkh return (x-x)/(x-x); /* acos(|x|>1) is NaN */ 512116Sjkh } 522116Sjkh if(ix<0x3f000000) { /* |x| < 0.5 */ 532116Sjkh if(ix<=0x23000000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/ 542116Sjkh z = x*x; 552116Sjkh p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); 562116Sjkh q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); 572116Sjkh r = p/q; 582116Sjkh return pio2_hi - (x - (pio2_lo-x*r)); 592116Sjkh } else if (hx<0) { /* x < -0.5 */ 602116Sjkh z = (one+x)*(float)0.5; 612116Sjkh p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); 622116Sjkh q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); 6323579Sbde s = __ieee754_sqrtf(z); 642116Sjkh r = p/q; 652116Sjkh w = r*s-pio2_lo; 662116Sjkh return pi - (float)2.0*(s+w); 672116Sjkh } else { /* x > 0.5 */ 682116Sjkh int32_t idf; 692116Sjkh z = (one-x)*(float)0.5; 7023579Sbde s = __ieee754_sqrtf(z); 712116Sjkh df = s; 722116Sjkh GET_FLOAT_WORD(idf,df); 732116Sjkh SET_FLOAT_WORD(df,idf&0xfffff000); 742116Sjkh c = (z-df*df)/(s+df); 752116Sjkh p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); 762116Sjkh q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); 772116Sjkh r = p/q; 782116Sjkh w = r*s+c; 792116Sjkh return (float)2.0*(df+w); 802116Sjkh } 812116Sjkh} 82