X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmath%2Fmodfl.c;h=a47b1924f75d1125b712e3ccf5b0f39af27fd8f2;hb=42aa19a0fefc5c38f6e00734afae80d42ab3bd48;hp=fc85bb58f78f6443069a40b8648e0017dc62078e;hpb=ee2ee92d62c43f6658d37ddea4c316d2089d0fe9;p=musl diff --git a/src/math/modfl.c b/src/math/modfl.c index fc85bb58..a47b1924 100644 --- a/src/math/modfl.c +++ b/src/math/modfl.c @@ -3,18 +3,20 @@ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 long double modfl(long double x, long double *iptr) { - return modf(x, (double *)iptr); + double d; + long double r; + + r = modf(x, &d); + *iptr = d; + return r; } #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384 -#if LDBL_MANT_DIG == 64 -#define TOINT 0x1p63 -#elif LDBL_MANT_DIG == 113 -#define TOINT 0x1p112 -#endif + +static const long double toint = 1/LDBL_EPSILON; + long double modfl(long double x, long double *iptr) { union ldshape u = {x}; - uint64_t mask; int e = (u.i.se & 0x7fff) - 0x3fff; int s = u.i.se >> 15; long double absx; @@ -36,7 +38,7 @@ long double modfl(long double x, long double *iptr) /* raises spurious inexact */ absx = s ? -x : x; - y = absx + TOINT - TOINT - absx; + y = absx + toint - toint - absx; if (y == 0) { *iptr = x; return s ? -0.0 : 0.0;