X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmath%2Fmodff.c;h=639514effafcc91997d53f4b8528e16b21440a9e;hb=76f440cff73878a7359e944618a7722dfd23bdec;hp=bf6e4ced1a8d461946834c1ec26481db29106dcb;hpb=634c3a63027aa4a693b64fae0e2f6e1635558e93;p=musl diff --git a/src/math/modff.c b/src/math/modff.c index bf6e4ced..639514ef 100644 --- a/src/math/modff.c +++ b/src/math/modff.c @@ -2,32 +2,33 @@ float modff(float x, float *iptr) { - uint32_t u, mask; - int e; - - GET_FLOAT_WORD(u, x); - e = (int)(u>>23 & 0xff) - 0x7f; + union {float f; uint32_t i;} u = {x}; + uint32_t mask; + int e = (int)(u.i>>23 & 0xff) - 0x7f; /* no fractional part */ if (e >= 23) { *iptr = x; - if (e == 0x80 && u<<9 != 0) /* nan */ + if (e == 0x80 && u.i<<9 != 0) { /* nan */ return x; - SET_FLOAT_WORD(x, u & 0x80000000); - return x; + } + u.i &= 0x80000000; + return u.f; } /* no integral part */ if (e < 0) { - SET_FLOAT_WORD(*iptr, u & 0x80000000); + u.i &= 0x80000000; + *iptr = u.f; return x; } mask = 0x007fffff>>e; - if ((u & mask) == 0) { + if ((u.i & mask) == 0) { *iptr = x; - SET_FLOAT_WORD(x, u & 0x80000000); - return x; + u.i &= 0x80000000; + return u.f; } - SET_FLOAT_WORD(*iptr, u & ~mask); - return x - *iptr; + u.i &= ~mask; + *iptr = u.f; + return x - u.f; }