X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmath%2Fscalbnf.c;h=0b62c3c71f85d4b72a21a9b39752fb77ce0caf10;hb=c243d6f09570010a448789dd296b14b7a61cb2ea;hp=243dafdf9e915e725e32e078414909856ea9210b;hpb=8051e08e10d2b739fcfcbc6bc7466e8d77fa49f1;p=musl diff --git a/src/math/scalbnf.c b/src/math/scalbnf.c index 243dafdf..0b62c3c7 100644 --- a/src/math/scalbnf.c +++ b/src/math/scalbnf.c @@ -1,28 +1,31 @@ -#include "libm.h" +#include +#include float scalbnf(float x, int n) { - float scale; + union {float f; uint32_t i;} u; + float_t y = x; if (n > 127) { - x *= 0x1p127f; + y *= 0x1p127f; n -= 127; if (n > 127) { - x *= 0x1p127f; + y *= 0x1p127f; n -= 127; if (n > 127) - return x * 0x1p127f; + n = 127; } } else if (n < -126) { - x *= 0x1p-126f; + y *= 0x1p-126f; n += 126; if (n < -126) { - x *= 0x1p-126f; + y *= 0x1p-126f; n += 126; if (n < -126) - return x * 0x1p-126f; + n = -126; } } - SET_FLOAT_WORD(scale, (uint32_t)(0x7f+n)<<23); - return x * scale; + u.i = (uint32_t)(0x7f+n)<<23; + x = y * u.f; + return x; }