summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraiju <devnull@localhost>2018-05-05 12:03:45 +0000
committeraiju <devnull@localhost>2018-05-05 12:03:45 +0000
commita7a07b2d43529b60a239bbb2c7acabcbdbb812e5 (patch)
tree6141e4ae6fd337d8ec2effae6df615ed16c04e9d
parent0930daf295aaeca0e58e1cb73a60b78c85749fe9 (diff)
downloadplan9front-a7a07b2d43529b60a239bbb2c7acabcbdbb812e5.tar.xz
mpdiv: get signs right...
-rw-r--r--sys/src/libmp/port/mpdiv.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/src/libmp/port/mpdiv.c b/sys/src/libmp/port/mpdiv.c
index 218f0232f..d6eea6d4b 100644
--- a/sys/src/libmp/port/mpdiv.c
+++ b/sys/src/libmp/port/mpdiv.c
@@ -52,10 +52,6 @@ mpdiv(mpint *dividend, mpint *divisor, mpint *quotient, mpint *remainder)
qsign = divisor->sign * dividend->sign;
rsign = dividend->sign;
- if(quotient != nil)
- quotient->sign = qsign;
- if(remainder != nil)
- remainder->sign = rsign;
// D1: shift until divisor, v, has hi bit set (needed to make trial
// divisor accurate)
@@ -128,11 +124,15 @@ mpdiv(mpint *dividend, mpint *divisor, mpint *quotient, mpint *remainder)
if(qp != nil){
assert((quotient->flags & MPtimesafe) == 0);
mpnorm(quotient);
+ if(quotient->top != 0)
+ quotient->sign = qsign;
}
if(remainder != nil){
assert((remainder->flags & MPtimesafe) == 0);
mpright(u, s, remainder); // u is the remainder shifted
+ if(remainder->top != 0)
+ remainder->sign = rsign;
}
mpfree(t);