summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-13 15:15:07 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-13 15:15:07 +0000
commit65575bab02a2ff13b1b41f2c47b934f0c8b44002 (patch)
tree027cb0e8240c5f655c735a5b80a69bbb552e41d9 /bignum.c
parent51c43dba6aa19c8998032f7a1ba730743dbaafed (diff)
* bignum.c (bigdivrem): Zero test condition simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/bignum.c b/bignum.c
index a02f4c4d99..cada8d0658 100644
--- a/bignum.c
+++ b/bignum.c
@@ -3762,11 +3762,14 @@ bigdivrem(VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp)
BDIGIT_DBL t2;
BDIGIT dd, q;
- if (BIGZEROP(y)) rb_num_zerodiv();
- xds = BDIGITS(x);
yds = BDIGITS(y);
+ while (0 < ny && !yds[ny-1]) ny--;
+ if (ny == 0)
+ rb_num_zerodiv();
+
+ xds = BDIGITS(x);
while (0 < nx && !xds[nx-1]) nx--;
- while (!yds[ny-1]) ny--;
+
if (nx < ny || (nx == ny && xds[nx - 1] < yds[ny - 1])) {
if (divp) *divp = rb_int2big(0);
if (modp) *modp = x;