X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmath%2Fremquo.c;h=085466e6a2f84ba16bdabfe8eb6d94bfa7e8a7b1;hb=aaa9eb5101e3a748218fb9373dd9655b50582da2;hp=79c9a55e02afa85b55660233ab93a41147b09c6c;hpb=b69f695acedd4ce2798ef9ea28d834ceccc789bd;p=musl diff --git a/src/math/remquo.c b/src/math/remquo.c index 79c9a55e..085466e6 100644 --- a/src/math/remquo.c +++ b/src/math/remquo.c @@ -35,7 +35,6 @@ double remquo(double x, double y, int *quo) hy &= 0x7fffffff; /* |y| */ /* purge off exception values */ - // FIXME: signed shift if ((hy|ly) == 0 || hx >= 0x7ff00000 || /* y = 0, or x not finite */ (hy|((ly|-ly)>>31)) > 0x7ff00000) /* or y is NaN */ return (x*y)/(x*y); @@ -45,7 +44,7 @@ double remquo(double x, double y, int *quo) goto fixup; } if (lx == ly) { /* |x| = |y| return x*0 */ - *quo = 1; + *quo = sxy ? -1 : 1; return Zero[(uint32_t)sx>>31]; } } @@ -128,6 +127,7 @@ double remquo(double x, double y, int *quo) /* convert back to floating value and restore the sign */ if ((hx|lx) == 0) { /* return sign(x)*0 */ + q &= 0x7fffffff; *quo = sxy ? -q : q; return Zero[(uint32_t)sx>>31]; } @@ -145,10 +145,10 @@ double remquo(double x, double y, int *quo) hx >>= n; } else if (n <= 31) { lx = (hx<<(32-n))|(lx>>n); - hx = sx; + hx = 0; } else { lx = hx>>(n-32); - hx = sx; + hx = 0; } } fixup: