diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-11 06:30:56 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-11 06:30:56 +0000 |
| commit | 9a21bc92278e23bf7fc774997aaa1a3e62989d8f (patch) | |
| tree | dcec484f4fcee1e60b9bbf36ae8d17c00e85edfd | |
| parent | 5a4f1cb7e702a322f2f63a2845d0f8fbd1e443a6 (diff) | |
| download | ruby-9a21bc92278e23bf7fc774997aaa1a3e62989d8f.tar.gz ruby-9a21bc92278e23bf7fc774997aaa1a3e62989d8f.tar.xz ruby-9a21bc92278e23bf7fc774997aaa1a3e62989d8f.zip | |
* bignum.c (bigdivrem): adjust length for division and remainder.
a patch from TOYOFUKU Chikanobu <nobu_toyofuku at nifty.com> in
[ruby-dev:36231].
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | bignum.c | 2 |
2 files changed, 8 insertions, 0 deletions
@@ -1,3 +1,9 @@ +Thu Sep 11 15:23:26 2008 Yukihiro Matsumoto <matz@ruby-lang.org> + + * bignum.c (bigdivrem): adjust length for division and remainder. + a patch from TOYOFUKU Chikanobu <nobu_toyofuku at nifty.com> in + [ruby-dev:36231]. + Thu Sep 11 02:59:47 2008 Tanaka Akira <akr@fsij.org> * io.c (io_binwrite): extracted from io_fwrite. @@ -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)); } |
