Fix pow and powf undefined behavior in libm.

This commit is contained in:
Jonas 'Sortie' Termansen 2016-01-05 20:40:07 +01:00
parent a43c89650f
commit 0eeb9d1e56
2 changed files with 2 additions and 2 deletions

View File

@ -296,7 +296,7 @@ __ieee754_pow(double x, double y)
r = (z*t1)/(t1-two)-(w+z*w);
z = one-(r-z);
GET_HIGH_WORD(j,z);
j += (n<<20);
j = (int32_t)((uint32_t)j + ((uint32_t)u<<20));
if((j>>20)<=0) z = scalbn(z,n); /* subnormal output */
else SET_HIGH_WORD(z,j);
return s*z;

View File

@ -240,7 +240,7 @@ __ieee754_powf(float x, float y)
r = (z*t1)/(t1-two)-(w+z*w);
z = one-(r-z);
GET_FLOAT_WORD(j,z);
j += (n<<23);
j = (int32_t)((uint32_t)j + ((uint32_t)u<<23));
if((j>>23)<=0) z = scalbnf(z,n); /* subnormal output */
else SET_FLOAT_WORD(z,j);
return s*z;