Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/boost/decimal/decimal128_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ constexpr decimal128_t::decimal128_t(T1 coeff, T2 exp, bool sign) noexcept
{
if (coeff > detail::d128_max_significand_value || biased_exp < 0)
{
coeff_digits = detail::coefficient_rounding<decimal128_t>(coeff, exp, biased_exp, sign);
coeff_digits = detail::coefficient_rounding<decimal128_t>(coeff, exp, biased_exp, sign, detail::num_digits(coeff));
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/boost/decimal/decimal32_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ constexpr decimal32_t::decimal32_t(T1 coeff, T2 exp, bool sign) noexcept // NOLI
auto biased_exp {static_cast<int>(exp + detail::bias)};
if (coeff > detail::d32_max_significand_value || biased_exp < 0)
{
coeff_digits = detail::coefficient_rounding<decimal32_t>(coeff, exp, biased_exp, sign);
coeff_digits = detail::coefficient_rounding<decimal32_t>(coeff, exp, biased_exp, sign, detail::num_digits(coeff));
}

auto reduced_coeff {static_cast<significand_type>(coeff)};
Expand Down
2 changes: 1 addition & 1 deletion include/boost/decimal/decimal64_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ constexpr decimal64_t::decimal64_t(T1 coeff, T2 exp, bool sign) noexcept
auto biased_exp {static_cast<int>(exp) + detail::bias_v<decimal64_t>};
if (coeff > detail::d64_max_significand_value || biased_exp < 0)
{
coeff_digits = detail::coefficient_rounding<decimal64_t>(coeff, exp, biased_exp, sign);
coeff_digits = detail::coefficient_rounding<decimal64_t>(coeff, exp, biased_exp, sign, detail::num_digits(coeff));
}

auto reduced_coeff {static_cast<significand_type>(coeff)};
Expand Down
4 changes: 1 addition & 3 deletions include/boost/decimal/detail/fenv_rounding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,12 @@ constexpr auto fenv_round(T& val, bool is_neg = false, bool sticky = false) noex
#endif

template <typename TargetDecimalType, typename T1, typename T2, typename T3>
constexpr auto coefficient_rounding(T1& coeff, T2& exp, T3& biased_exp, const bool sign) noexcept
constexpr auto coefficient_rounding(T1& coeff, T2& exp, T3& biased_exp, const bool sign, int coeff_digits) noexcept
{
// T1 will be a 128-bit or 256-bit
using sig_type = typename TargetDecimalType::significand_type;
using demoted_integer_type = std::conditional_t<std::numeric_limits<T1>::digits10 < std::numeric_limits<sig_type>::digits10, T1, sig_type>;

auto coeff_digits {detail::num_digits(coeff)};

// How many digits need to be shifted?
const auto shift_for_large_coeff {(coeff_digits - detail::precision_v<TargetDecimalType>) - 1};
int shift {};
Expand Down
2 changes: 1 addition & 1 deletion include/boost/decimal/detail/normalize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ constexpr auto normalize(T1& significand, T2& exp, bool sign = false) noexcept -
else if (digits > target_precision)
{
auto biased_exp {static_cast<int>(exp) + detail::bias_v<TargetDecimalType>};
detail::coefficient_rounding<TargetDecimalType>(significand, exp, biased_exp, sign);
detail::coefficient_rounding<TargetDecimalType>(significand, exp, biased_exp, sign, digits);
}
}

Expand Down