diff options
Diffstat (limited to 'boost/multiprecision/cpp_bin_float')
-rw-r--r-- | boost/multiprecision/cpp_bin_float/io.hpp | 10 | ||||
-rw-r--r-- | boost/multiprecision/cpp_bin_float/transcendental.hpp | 3 |
2 files changed, 7 insertions, 6 deletions
diff --git a/boost/multiprecision/cpp_bin_float/io.hpp b/boost/multiprecision/cpp_bin_float/io.hpp index 630d651d9d..8a3faaa4ff 100644 --- a/boost/multiprecision/cpp_bin_float/io.hpp +++ b/boost/multiprecision/cpp_bin_float/io.hpp @@ -485,7 +485,7 @@ std::string cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::s if(exponent() <= cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent) { // How far to left-shift in order to demormalise the mantissa: - boost::intmax_t shift = (int)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - exponent() - 1; + boost::intmax_t shift = (boost::intmax_t)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - (boost::intmax_t)exponent() - 1; boost::intmax_t digits_wanted = static_cast<int>(dig); boost::intmax_t base10_exp = exponent() >= 0 ? static_cast<boost::intmax_t>(std::floor(0.30103 * exponent())) : static_cast<boost::intmax_t>(std::ceil(0.30103 * exponent())); // @@ -571,7 +571,7 @@ std::string cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::s #else max_bits *= 2; #endif - shift = (int)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - exponent() - 1 - power10; + shift = (boost::intmax_t)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - exponent() - 1 - power10; continue; } } @@ -599,7 +599,7 @@ std::string cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::s #else max_bits *= 2; #endif - shift = (int)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - exponent() - 1 - power10; + shift = (boost::intmax_t)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - exponent() - 1 - power10; continue; } if(shift) @@ -612,7 +612,7 @@ std::string cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::s #else max_bits *= 2; #endif - shift = (int)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - exponent() - 1 - power10; + shift = (boost::intmax_t)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - exponent() - 1 - power10; continue; } i >>= shift; @@ -646,7 +646,7 @@ std::string cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::s if(fixed) digits_wanted = digits_got; // strange but true. power10 = digits_wanted - base10_exp - 1; - shift = (int)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - exponent() - 1 - power10; + shift = (boost::intmax_t)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - exponent() - 1 - power10; if(fixed) break; roundup = 0; diff --git a/boost/multiprecision/cpp_bin_float/transcendental.hpp b/boost/multiprecision/cpp_bin_float/transcendental.hpp index 604ed85159..5c969716a5 100644 --- a/boost/multiprecision/cpp_bin_float/transcendental.hpp +++ b/boost/multiprecision/cpp_bin_float/transcendental.hpp @@ -124,13 +124,14 @@ void eval_exp(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> BOOST_ASSERT(t.compare(default_ops::get_constant_ln2<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> >()) < 0); k = nn ? Exponent(1) << (msb(nn) / 2) : 0; + k = (std::min)(k, (Exponent)(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count / 4)); eval_ldexp(t, t, -k); eval_exp_taylor(res, t); // // Square 1 + res k times: // - for(int s = 0; s < k; ++s) + for(Exponent s = 0; s < k; ++s) { t.swap(res); eval_multiply(res, t, t); |