summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-06 02:39:39 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-06 02:39:39 +0000
commit0dedfa849c885b52745e46ec0620cf01a1533fbc (patch)
tree2cdea2d4e411a1d5243d2c939ab14547190b6458 /bignum.c
parentecd1aab5266315f947b0568cb56fab4f63453c83 (diff)
bignum divmod bug
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/bignum.c b/bignum.c
index c40f94f4d8..dabb96a82e 100644
--- a/bignum.c
+++ b/bignum.c
@@ -804,7 +804,10 @@ bigdivmod(x, y, div, mod, modulo)
RBIGNUM(z)->sign = RBIGNUM(x)->sign==RBIGNUM(y)->sign;
if (div) *div = bignorm(z);
if (mod) {
- if (!RBIGNUM(y)->sign) t2 = -(long)t2;
+ if (!RBIGNUM(x)->sign) t2 = -(long)t2;
+ if (modulo && RBIGNUM(x)->sign != RBIGNUM(y)->sign) {
+ t2 = t2 + yds[0] * (RBIGNUM(y)->sign ? 1 : -1);
+ }
*mod = INT2NUM(t2);
}
return;