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/gmp.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/gmp.hpp')
-rw-r--r-- | boost/multiprecision/gmp.hpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/boost/multiprecision/gmp.hpp b/boost/multiprecision/gmp.hpp index d08e7080e5..0f5800ed3d 100644 --- a/boost/multiprecision/gmp.hpp +++ b/boost/multiprecision/gmp.hpp @@ -342,8 +342,19 @@ struct gmp_float_imp } else if(digits > 0) { + mp_exp_t old_e = e; ps = mpf_get_str (0, &e, 10, static_cast<std::size_t>(digits), m_data); --e; // To match with what our formatter expects. + if (old_e > e) + { + // in some cases, when we ask for more digits of precision, it will + // change the number of digits to the left of the decimal, if that + // happens, account for it here. + // example: cout << fixed << setprecision(3) << mpf_float_50("99.9809") + digits -= old_e - e; + ps = mpf_get_str (0, &e, 10, static_cast<std::size_t>(digits), m_data); + --e; // To match with what our formatter expects. + } } else { |