e_acosf.c revision 8870
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 178870Srgrimesstatic char rcsid[] = "$Id: e_acosf.c,v 1.1.1.1 1994/08/19 09:39:43 jkh Exp $"; 182116Sjkh#endif 192116Sjkh 202116Sjkh#include "math.h" 212116Sjkh#include "math_private.h" 222116Sjkh 232116Sjkh#ifdef __STDC__ 248870Srgrimesstatic const float 252116Sjkh#else 268870Srgrimesstatic float 272116Sjkh#endif 282116Sjkhone = 1.0000000000e+00, /* 0x3F800000 */ 292116Sjkhpi = 3.1415925026e+00, /* 0x40490fda */ 302116Sjkhpio2_hi = 1.5707962513e+00, /* 0x3fc90fda */ 312116Sjkhpio2_lo = 7.5497894159e-08, /* 0x33a22168 */ 322116SjkhpS0 = 1.6666667163e-01, /* 0x3e2aaaab */ 332116SjkhpS1 = -3.2556581497e-01, /* 0xbea6b090 */ 342116SjkhpS2 = 2.0121252537e-01, /* 0x3e4e0aa8 */ 352116SjkhpS3 = -4.0055535734e-02, /* 0xbd241146 */ 362116SjkhpS4 = 7.9153501429e-04, /* 0x3a4f7f04 */ 372116SjkhpS5 = 3.4793309169e-05, /* 0x3811ef08 */ 382116SjkhqS1 = -2.4033949375e+00, /* 0xc019d139 */ 392116SjkhqS2 = 2.0209457874e+00, /* 0x4001572d */ 402116SjkhqS3 = -6.8828397989e-01, /* 0xbf303361 */ 412116SjkhqS4 = 7.7038154006e-02; /* 0x3d9dc62e */ 422116Sjkh 432116Sjkh#ifdef __STDC__ 442116Sjkh float __ieee754_acosf(float x) 452116Sjkh#else 462116Sjkh float __ieee754_acosf(x) 472116Sjkh float x; 482116Sjkh#endif 492116Sjkh{ 502116Sjkh float z,p,q,r,w,s,c,df; 512116Sjkh int32_t hx,ix; 522116Sjkh GET_FLOAT_WORD(hx,x); 532116Sjkh ix = hx&0x7fffffff; 542116Sjkh if(ix==0x3f800000) { /* |x|==1 */ 552116Sjkh if(hx>0) return 0.0; /* acos(1) = 0 */ 562116Sjkh else return pi+(float)2.0*pio2_lo; /* acos(-1)= pi */ 572116Sjkh } else if(ix>0x3f800000) { /* |x| >= 1 */ 582116Sjkh return (x-x)/(x-x); /* acos(|x|>1) is NaN */ 592116Sjkh } 602116Sjkh if(ix<0x3f000000) { /* |x| < 0.5 */ 612116Sjkh if(ix<=0x23000000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/ 622116Sjkh z = x*x; 632116Sjkh p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); 642116Sjkh q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); 652116Sjkh r = p/q; 662116Sjkh return pio2_hi - (x - (pio2_lo-x*r)); 672116Sjkh } else if (hx<0) { /* x < -0.5 */ 682116Sjkh z = (one+x)*(float)0.5; 692116Sjkh p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); 702116Sjkh q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); 712116Sjkh s = sqrtf(z); 722116Sjkh r = p/q; 732116Sjkh w = r*s-pio2_lo; 742116Sjkh return pi - (float)2.0*(s+w); 752116Sjkh } else { /* x > 0.5 */ 762116Sjkh int32_t idf; 772116Sjkh z = (one-x)*(float)0.5; 782116Sjkh s = sqrtf(z); 792116Sjkh df = s; 802116Sjkh GET_FLOAT_WORD(idf,df); 812116Sjkh SET_FLOAT_WORD(df,idf&0xfffff000); 822116Sjkh c = (z-df*df)/(s+df); 832116Sjkh p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); 842116Sjkh q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); 852116Sjkh r = p/q; 862116Sjkh w = r*s+c; 872116Sjkh return (float)2.0*(df+w); 882116Sjkh } 892116Sjkh} 90