aboutsummaryrefslogtreecommitdiffstats
path: root/bignum.c
diff options
context:
space:
mode:
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/bignum.c b/bignum.c
index 3e4ac0dea1..a3f8d25a61 100644
--- a/bignum.c
+++ b/bignum.c
@@ -1749,6 +1749,7 @@ bigdivrem(VALUE x, VALUE y, VALUE *divp, VALUE *modp)
zds = BDIGITS(*divp);
j = (nx==ny ? nx+2 : nx+1) - ny;
for (i = 0;i < j;i++) zds[i] = zds[i+ny];
+ if (!zds[i-1]) i--;
RBIGNUM_SET_LEN(*divp, i);
}
if (modp) { /* normalize remainder */
@@ -1764,6 +1765,7 @@ bigdivrem(VALUE x, VALUE y, VALUE *divp, VALUE *modp)
t2 = BIGUP(q);
}
}
+ if (!zds[ny-1]) ny--;
RBIGNUM_SET_LEN(*modp, ny);
RBIGNUM_SET_SIGN(*modp, RBIGNUM_SIGN(x));
}