diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:22:41 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:22:41 +0900 |
commit | 3c1df2168531ad5580076ae08d529054689aeedd (patch) | |
tree | 941aff6f86393eecacddfec252a8508c7e8351c9 /boost/multiprecision/cpp_bin_float/transcendental.hpp | |
parent | d6a306e745acfee00e81ccaf3324a2a03516db41 (diff) | |
download | boost-3c1df2168531ad5580076ae08d529054689aeedd.tar.gz boost-3c1df2168531ad5580076ae08d529054689aeedd.tar.bz2 boost-3c1df2168531ad5580076ae08d529054689aeedd.zip |
Imported Upstream version 1.70.0upstream/1.70.0
Diffstat (limited to 'boost/multiprecision/cpp_bin_float/transcendental.hpp')
-rw-r--r-- | boost/multiprecision/cpp_bin_float/transcendental.hpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/boost/multiprecision/cpp_bin_float/transcendental.hpp b/boost/multiprecision/cpp_bin_float/transcendental.hpp index 5c969716a5..5c1842dc7e 100644 --- a/boost/multiprecision/cpp_bin_float/transcendental.hpp +++ b/boost/multiprecision/cpp_bin_float/transcendental.hpp @@ -64,6 +64,7 @@ void eval_exp(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> using default_ops::eval_subtract; using default_ops::eval_add; using default_ops::eval_convert_to; + using default_ops::eval_increment; int type = eval_fpclassify(arg); bool isneg = eval_get_sign(arg) < 0; @@ -104,6 +105,13 @@ void eval_exp(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> eval_multiply(t, n, default_ops::get_constant_ln2<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> >()); eval_subtract(t, arg); t.negate(); + if (t.compare(default_ops::get_constant_ln2<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> >()) > 0) + { + // There are some rare cases where the multiply rounds down leaving a remainder > ln2 + // See https://github.com/boostorg/multiprecision/issues/120 + eval_increment(n); + t = limb_type(0); + } if(eval_get_sign(t) < 0) { // There are some very rare cases where arg/ln2 is an integer, and the subsequent multiply |