X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmath%2Fremainderf.c;h=77671039437b3c4b64acc5ff270936c838313935;hb=74025c80ce1eb4cda110ab2e3ac11718d3c6f2ff;hp=c17bb4f434d2f81eacc24f04838a26fc999c727d;hpb=b69f695acedd4ce2798ef9ea28d834ceccc789bd;p=musl diff --git a/src/math/remainderf.c b/src/math/remainderf.c index c17bb4f4..77671039 100644 --- a/src/math/remainderf.c +++ b/src/math/remainderf.c @@ -15,8 +15,6 @@ #include "libm.h" -static const float zero = 0.0; - float remainderf(float x, float p) { int32_t hx,hp; @@ -30,16 +28,13 @@ float remainderf(float x, float p) hx &= 0x7fffffff; /* purge off exception values */ - if (hp == 0) /* p = 0 */ + if (hp == 0 || hx >= 0x7f800000 || hp > 0x7f800000) /* p = 0, x not finite, p is NaN */ return (x*p)/(x*p); - if (hx >= 0x7f800000 || hp > 0x7f800000) /* x not finite, p is NaN */ - // FIXME: why long double? - return ((long double)x*p)/((long double)x*p); if (hp <= 0x7effffff) x = fmodf(x, p + p); /* now x < 2p */ if (hx - hp == 0) - return zero*x; + return 0.0f*x; x = fabsf(x); p = fabsf(p); if (hp < 0x01000000) { @@ -49,7 +44,7 @@ float remainderf(float x, float p) x -= p; } } else { - p_half = (float)0.5*p; + p_half = 0.5f*p; if (x > p_half) { x -= p; if (x >= p_half)