aboutsummaryrefslogtreecommitdiffstats
path: root/bignum.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-25 08:47:22 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-25 08:47:22 +0000
commitfd0b6ef3fb566996121971ada06b1d2ba847d8d0 (patch)
treea75620e9800917a0c5fc9183d6f3fbc186dd533b /bignum.c
parent136131682807fefb8c7bd18a9417e456648e634a (diff)
downloadruby-fd0b6ef3fb566996121971ada06b1d2ba847d8d0.tar.gz
bignum.c: precise fdiv
* bignum.c (big_fdiv): more precise calculation. [ruby-dev:49915] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57179 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 41b1043b99..bc283ac89a 100644
--- a/bignum.c
+++ b/bignum.c
@@ -6102,6 +6102,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);