summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-14 12:05:38 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-14 12:05:38 +0000
commit2f407300fac2f0b3143ccf4db4d7ba57266ce12b (patch)
tree16bea306a32d34e00477dad81a96e9ab4979aaa4 /bignum.c
parent48bfbb574ea4112fdaf5d542a2c8d9918afd9237 (diff)
* bignum.c (bigdivrem): Reduce number of digits before bignew() for div.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/bignum.c b/bignum.c
index ddb889a284..ecd834726c 100644
--- a/bignum.c
+++ b/bignum.c
@@ -3848,11 +3848,11 @@ bigdivrem(VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp)
if (divp) { /* move quotient down in z */
j = nz - ny;
+ while (0 < j && !zds[j-1+ny])
+ j--;
*divp = zz = bignew(j, RBIGNUM_SIGN(x)==RBIGNUM_SIGN(y));
qds = BDIGITS(zz);
for (i = 0;i < j;i++) qds[i] = zds[i+ny];
- if (!qds[i-1])
- RBIGNUM_SET_LEN(zz, i-1);
}
if (modp) { /* normalize remainder */
while (ny > 1 && !zds[ny-1]) --ny;