summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-11 10:37:09 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-11 10:37:09 +0000
commit6c93dee7ed9eddf55431ae734502bad335f7e50a (patch)
treeeee2ddb6d51f0f8bed81ac943b75f3cbe6c92cb0 /bignum.c
parentb5154b0eb71f0b1c523a1361fff2221907c87fc5 (diff)
merge revision(s) 57179:
bignum.c: precise fdiv * bignum.c (big_fdiv): more precise calculation. [ruby-dev:49915] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@57832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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 bf234dba6a..a5983c4ba9 100644
--- a/bignum.c
+++ b/bignum.c
@@ -6101,6 +6101,8 @@ big_fdiv(VALUE x, VALUE y, long ey)
l = BIGNUM_LEN(x);
ex = l * BITSPERDIG - nlz(BDIGITS(x)[l-1]);
ex -= 2 * DBL_BIGDIG * BITSPERDIG;
+ if (ex > BITSPERDIG) ex -= BITSPERDIG;
+ else if (ex > 0) ex = 0;
if (ex) x = big_shift(x, ex);
bigdivrem(x, y, &z, 0);