Minor improvements:

- Improve the order of some tests.
- Fix style.

Submitted by:	bde
This commit is contained in:
das 2008-08-03 17:39:54 +00:00
parent 8883e5c019
commit e570127faf
3 changed files with 20 additions and 20 deletions

View File

@ -38,10 +38,11 @@ __ieee754_acosf(float x)
int32_t hx,ix;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
if(ix==0x3f800000) { /* |x|==1 */
if(hx>0) return 0.0; /* acos(1) = 0 */
else return pi+(float)2.0*pio2_lo; /* acos(-1)= pi */
} else if(ix>0x3f800000) { /* |x| >= 1 */
if(ix>=0x3f800000) { /* |x| >= 1 */
if(ix==0x3f800000) { /* |x| == 1 */
if(hx>0) return 0.0; /* acos(1) = 0 */
else return pi+(float)2.0*pio2_lo; /* acos(-1)= pi */
}
return (x-x)/(x-x); /* acos(|x|>1) is NaN */
}
if(ix<0x3f000000) { /* |x| < 0.5 */
@ -55,14 +56,14 @@ __ieee754_acosf(float x)
z = (one+x)*(float)0.5;
p = z*(pS0+z*(pS1+z*pS2));
q = one+z*qS1;
s = __ieee754_sqrtf(z);
s = sqrtf(z);
r = p/q;
w = r*s-pio2_lo;
return pi - (float)2.0*(s+w);
} else { /* x > 0.5 */
int32_t idf;
z = (one-x)*(float)0.5;
s = __ieee754_sqrtf(z);
s = sqrtf(z);
df = s;
GET_FLOAT_WORD(idf,df);
SET_FLOAT_WORD(df,idf&0xfffff000);

View File

@ -35,31 +35,30 @@ float
__ieee754_asinf(float x)
{
double s;
float t=0.0,w,p,q,c,r;
float t,w,p,q,c,r;
int32_t hx,ix;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
if(ix==0x3f800000) {
/* asin(1)=+-pi/2 with inexact */
return x*pio2;
} else if(ix> 0x3f800000) { /* |x|>= 1 */
if(ix>=0x3f800000) { /* |x| >= 1 */
if(ix==0x3f800000) /* |x| == 1 */
return x*pio2; /* asin(+-1) = +-pi/2 with inexact */
return (x-x)/(x-x); /* asin(|x|>1) is NaN */
} else if (ix<0x3f000000) { /* |x|<0.5 */
if(ix<0x39800000) { /* if |x| < 2**-12 */
if(ix<0x39800000) { /* |x| < 2**-12 */
if(huge+x>one) return x;/* return x with inexact if x!=0*/
} else
t = x*x;
p = t*(pS0+t*(pS1+t*pS2));
q = one+t*qS1;
w = p/q;
return x+x*w;
}
t = x*x;
p = t*(pS0+t*(pS1+t*pS2));
q = one+t*qS1;
w = p/q;
return x+x*w;
}
/* 1> |x|>= 0.5 */
w = one-fabsf(x);
t = w*(float)0.5;
p = t*(pS0+t*(pS1+t*pS2));
q = one+t*qS1;
s = __ieee754_sqrt(t);
s = sqrt(t);
w = p/q;
t = pio2-2.0*(s+s*w);
if(hx>0) return t; else return -t;

View File

@ -84,7 +84,7 @@ __ieee754_atan2f(float y, float x)
z=pi_o_2+(float)0.5*pi_lo;
m&=1;
}
else if(hx<0&&k<-26) z=0.0; /* 0 > |y|/x > -2**-26 */
else if(k<-26&&hx<0) z=0.0; /* 0 > |y|/x > -2**-26 */
else z=atanf(fabsf(y/x)); /* safe to do y/x */
switch (m) {
case 0: return z ; /* atan(+,+) */