aboutsummaryrefslogtreecommitdiffstats
path: root/bignum.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-15 15:29:09 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-15 15:29:09 +0000
commitdf76f366a7be0a10deb4ab475ec4c5966d975ce2 (patch)
treec401b290b4b11c7abd30e45b33d35f8af41a0684 /bignum.c
parent5fb0f3f0220dfcbde3cbd8166d80fcd0916e041b (diff)
downloadruby-df76f366a7be0a10deb4ab475ec4c5966d975ce2.tar.gz
bignum.c: fix inexact estimation
* bignum.c (estimate_initial_sqrt): estimated square root is inexact if it is not equal to its ceil, needs Newton's method. [ruby-core:80696] [Bug #13440] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/bignum.c b/bignum.c
index d1e83565c9..3207af9616 100644
--- a/bignum.c
+++ b/bignum.c
@@ -6824,6 +6824,9 @@ estimate_initial_sqrt(VALUE *xp, const size_t xn, const BDIGIT *nds, size_t len)
if (lowbits || (lowbits = !bary_zero_p(nds, len-dbl_per_bdig)))
++d;
}
+ else {
+ lowbits = 1;
+ }
rshift /= 2;
rshift += (2-(len&1))*BITSPERDIG/2;
if (rshift >= 0) {