|
Packit |
6c4009 |
/* e_acosf.c -- float version of e_acos.c.
|
|
Packit |
6c4009 |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/*
|
|
Packit |
6c4009 |
* ====================================================
|
|
Packit |
6c4009 |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
|
Packit |
6c4009 |
*
|
|
Packit |
6c4009 |
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
Packit |
6c4009 |
* Permission to use, copy, modify, and distribute this
|
|
Packit |
6c4009 |
* software is freely granted, provided that this notice
|
|
Packit |
6c4009 |
* is preserved.
|
|
Packit |
6c4009 |
* ====================================================
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <math.h>
|
|
Packit |
6c4009 |
#include <math_private.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
static const float
|
|
Packit |
6c4009 |
one = 1.0000000000e+00, /* 0x3F800000 */
|
|
Packit |
6c4009 |
pi = 3.1415925026e+00, /* 0x40490fda */
|
|
Packit |
6c4009 |
pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */
|
|
Packit |
6c4009 |
pio2_lo = 7.5497894159e-08, /* 0x33a22168 */
|
|
Packit |
6c4009 |
pS0 = 1.6666667163e-01, /* 0x3e2aaaab */
|
|
Packit |
6c4009 |
pS1 = -3.2556581497e-01, /* 0xbea6b090 */
|
|
Packit |
6c4009 |
pS2 = 2.0121252537e-01, /* 0x3e4e0aa8 */
|
|
Packit |
6c4009 |
pS3 = -4.0055535734e-02, /* 0xbd241146 */
|
|
Packit |
6c4009 |
pS4 = 7.9153501429e-04, /* 0x3a4f7f04 */
|
|
Packit |
6c4009 |
pS5 = 3.4793309169e-05, /* 0x3811ef08 */
|
|
Packit |
6c4009 |
qS1 = -2.4033949375e+00, /* 0xc019d139 */
|
|
Packit |
6c4009 |
qS2 = 2.0209457874e+00, /* 0x4001572d */
|
|
Packit |
6c4009 |
qS3 = -6.8828397989e-01, /* 0xbf303361 */
|
|
Packit |
6c4009 |
qS4 = 7.7038154006e-02; /* 0x3d9dc62e */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
float
|
|
Packit |
6c4009 |
__ieee754_acosf(float x)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
float z,p,q,r,w,s,c,df;
|
|
Packit |
6c4009 |
int32_t hx,ix;
|
|
Packit |
6c4009 |
GET_FLOAT_WORD(hx,x);
|
|
Packit |
6c4009 |
ix = hx&0x7fffffff;
|
|
Packit |
6c4009 |
if(ix==0x3f800000) { /* |x|==1 */
|
|
Packit |
6c4009 |
if(hx>0) return 0.0; /* acos(1) = 0 */
|
|
Packit |
6c4009 |
else return pi+(float)2.0*pio2_lo; /* acos(-1)= pi */
|
|
Packit |
6c4009 |
} else if(ix>0x3f800000) { /* |x| >= 1 */
|
|
Packit |
6c4009 |
return (x-x)/(x-x); /* acos(|x|>1) is NaN */
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
if(ix<0x3f000000) { /* |x| < 0.5 */
|
|
Packit |
6c4009 |
if(ix<=0x32800000) return pio2_hi+pio2_lo;/*if|x|<=2**-26*/
|
|
Packit |
6c4009 |
z = x*x;
|
|
Packit |
6c4009 |
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
|
|
Packit |
6c4009 |
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
|
|
Packit |
6c4009 |
r = p/q;
|
|
Packit |
6c4009 |
return pio2_hi - (x - (pio2_lo-x*r));
|
|
Packit |
6c4009 |
} else if (hx<0) { /* x < -0.5 */
|
|
Packit |
6c4009 |
z = (one+x)*(float)0.5;
|
|
Packit |
6c4009 |
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
|
|
Packit |
6c4009 |
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
|
|
Packit |
6c4009 |
s = sqrtf(z);
|
|
Packit |
6c4009 |
r = p/q;
|
|
Packit |
6c4009 |
w = r*s-pio2_lo;
|
|
Packit |
6c4009 |
return pi - (float)2.0*(s+w);
|
|
Packit |
6c4009 |
} else { /* x > 0.5 */
|
|
Packit |
6c4009 |
int32_t idf;
|
|
Packit |
6c4009 |
z = (one-x)*(float)0.5;
|
|
Packit |
6c4009 |
s = sqrtf(z);
|
|
Packit |
6c4009 |
df = s;
|
|
Packit |
6c4009 |
GET_FLOAT_WORD(idf,df);
|
|
Packit |
6c4009 |
SET_FLOAT_WORD(df,idf&0xfffff000);
|
|
Packit |
6c4009 |
c = (z-df*df)/(s+df);
|
|
Packit |
6c4009 |
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
|
|
Packit |
6c4009 |
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
|
|
Packit |
6c4009 |
r = p/q;
|
|
Packit |
6c4009 |
w = r*s+c;
|
|
Packit |
6c4009 |
return (float)2.0*(df+w);
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
strong_alias (__ieee754_acosf, __acosf_finite)
|