1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-05 09:14:03 +00:00

Fix some rather obscene code that has ambiguous if...if...else...

constructs in it.
This commit is contained in:
David Schultz 2008-03-29 16:37:59 +00:00
parent 838200ff96
commit ee0730e61e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=177711
6 changed files with 36 additions and 10 deletions

View File

@ -107,8 +107,14 @@ __ieee754_log(double x)
k += (i>>20);
f = x-1.0;
if((0x000fffff&(2+hx))<3) { /* -2**-20 <= f < 2**-20 */
if(f==zero) if(k==0) return zero; else {dk=(double)k;
return dk*ln2_hi+dk*ln2_lo;}
if(f==zero) {
if(k==0) {
return zero;
} else {
dk=(double)k;
return dk*ln2_hi+dk*ln2_lo;
}
}
R = f*f*(0.5-0.33333333333333333*f);
if(k==0) return f-R; else {dk=(double)k;
return dk*ln2_hi-((R-dk*ln2_lo)-f);}

View File

@ -55,8 +55,14 @@ __ieee754_logf(float x)
k += (i>>23);
f = x-(float)1.0;
if((0x007fffff&(0x8000+ix))<0xc000) { /* -2**-9 <= f < 2**-9 */
if(f==zero) if(k==0) return zero; else {dk=(float)k;
return dk*ln2_hi+dk*ln2_lo;}
if(f==zero) {
if(k==0) {
return zero;
} else {
dk=(float)k;
return dk*ln2_hi+dk*ln2_lo;
}
}
R = f*f*((float)0.5-(float)0.33333333333333333*f);
if(k==0) return f-R; else {dk=(float)k;
return dk*ln2_hi-((R-dk*ln2_lo)-f);}

View File

@ -190,9 +190,10 @@ expm1(double x)
e = (x*(e-c)-c);
e -= hxs;
if(k== -1) return 0.5*(x-e)-0.5;
if(k==1)
if(k==1) {
if(x < -0.25) return -2.0*(e-(x+0.5));
else return one+2.0*(x-e);
}
if (k <= -2 || k>56) { /* suffice to return exp(x)-1 */
y = one-(e-x);
if (k == 1024) y = y*2.0*0x1p1023;

View File

@ -96,9 +96,10 @@ expm1f(float x)
e = (x*(e-c)-c);
e -= hxs;
if(k== -1) return (float)0.5*(x-e)-(float)0.5;
if(k==1)
if(k==1) {
if(x < (float)-0.25) return -(float)2.0*(e-(x+(float)0.5));
else return one+(float)2.0*(x-e);
}
if (k <= -2 || k>56) { /* suffice to return exp(x)-1 */
y = one-(e-x);
if (k == 128) y = y*2.0F*0x1p127F;

View File

@ -155,8 +155,14 @@ log1p(double x)
}
hfsq=0.5*f*f;
if(hu==0) { /* |f| < 2**-20 */
if(f==zero) if(k==0) return zero;
else {c += k*ln2_lo; return k*ln2_hi+c;}
if(f==zero) {
if(k==0) {
return zero;
} else {
c += k*ln2_lo;
return k*ln2_hi+c;
}
}
R = hfsq*(1.0-0.66666666666666666*f);
if(k==0) return f-R; else
return k*ln2_hi-((R-(k*ln2_lo+c))-f);

View File

@ -94,8 +94,14 @@ log1pf(float x)
}
hfsq=(float)0.5*f*f;
if(hu==0) { /* |f| < 2**-20 */
if(f==zero) if(k==0) return zero;
else {c += k*ln2_lo; return k*ln2_hi+c;}
if(f==zero) {
if(k==0) {
return zero;
} else {
c += k*ln2_lo;
return k*ln2_hi+c;
}
}
R = hfsq*((float)1.0-(float)0.66666666666666666*f);
if(k==0) return f-R; else
return k*ln2_hi-((R-(k*ln2_lo+c))-f);