diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-08-28 16:46:32 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-08-28 16:46:32 +0200 |
commit | 1f9bdb6f5d9699493f6bce572cbbb58ef3b4ad27 (patch) | |
tree | 8c217ab6648ee94f730fb5c9bedde3250b559243 /sys/src | |
parent | bdc87e17bd2522552f3c97c741bda0ae29df3528 (diff) |
libmp: mpdiv(): fix divisor==quotient case (again)
Diffstat (limited to 'sys/src')
-rw-r--r-- | sys/src/libmp/port/mpdiv.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/src/libmp/port/mpdiv.c b/sys/src/libmp/port/mpdiv.c index 2c2ce73eb..ea68acb43 100644 --- a/sys/src/libmp/port/mpdiv.c +++ b/sys/src/libmp/port/mpdiv.c @@ -24,10 +24,11 @@ mpdiv(mpint *dividend, mpint *divisor, mpint *quotient, mpint *remainder) if(divisor->top == 1 && (divisor->p[0] & divisor->p[0]-1) == 0){ vlong r = (vlong)dividend->sign * (dividend->p[0] & divisor->p[0]-1); if(quotient != nil){ + sign = divisor->sign; for(s = 0; ((divisor->p[0] >> s) & 1) == 0; s++) ; mpright(dividend, s, quotient); - if(divisor->sign < 0) + if(sign < 0) quotient->sign ^= (-mpmagcmp(quotient, mpzero) >> 31) << 1; } if(remainder != nil){ |