From 63471c7c3279ba5b152b170afcce5092ea62dda6 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 11 Sep 2008 06:30:56 +0000 Subject: * bignum.c (bigdivrem): adjust length for division and remainder. a patch from TOYOFUKU Chikanobu in [ruby-dev:36231]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ bignum.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 64dc2fbdd4..fc48ad3582 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Sep 11 15:23:26 2008 Yukihiro Matsumoto + + * bignum.c (bigdivrem): adjust length for division and remainder. + a patch from TOYOFUKU Chikanobu in + [ruby-dev:36231]. + Thu Sep 11 02:59:47 2008 Tanaka Akira * io.c (io_binwrite): extracted from io_fwrite. 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)); } -- cgit v1.2.3