summaryrefslogtreecommitdiff
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
commitc6eb59c439cf8b6375a2aba18265a06405a5c651 (patch)
treea75620e9800917a0c5fc9183d6f3fbc186dd533b
parent6335fc6fe31b7c8f20b398a8618d208c72950f94 (diff)
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
-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);