diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-15 15:29:09 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-15 15:29:09 +0000 |
commit | d117444cdaf2b07a8d723a03937955e345917902 (patch) | |
tree | c401b290b4b11c7abd30e45b33d35f8af41a0684 /bignum.c | |
parent | 6b75a0e118cad7bd26d870e12ea5b16d035c1d5e (diff) | |
download | ruby-d117444cdaf2b07a8d723a03937955e345917902.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.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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) { |