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
4 changes: 2 additions & 2 deletions include/boost/decimal/detail/fenv_rounding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ constexpr auto coefficient_rounding(T1& coeff, T2& exp, T3& biased_exp, const bo
using demoted_integer_type = std::conditional_t<std::numeric_limits<T1>::digits10 < std::numeric_limits<sig_type>::digits10, T1, sig_type>;

// How many digits need to be shifted?
const auto shift_for_large_coeff {(coeff_digits - detail::precision_v<TargetDecimalType>) - 1};
const int shift_for_large_coeff {(coeff_digits - detail::precision_v<TargetDecimalType>) - 1};
int shift {};
BOOST_DECIMAL_IF_CONSTEXPR (is_fast_type_v<TargetDecimalType>)
{
Expand All @@ -212,7 +212,7 @@ constexpr auto coefficient_rounding(T1& coeff, T2& exp, T3& biased_exp, const bo
}
else
{
const auto shift_for_small_exp {(-biased_exp) - 1};
const auto shift_for_small_exp {static_cast<int>((-biased_exp) - 1)};
shift = std::max(shift_for_small_exp, shift_for_large_coeff);
}

Expand Down
6 changes: 3 additions & 3 deletions include/boost/decimal/detail/mul_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ constexpr auto d128_mul_impl(const T1& lhs_sig, const U1 lhs_exp, const bool lhs

// 34 is the number of digits in the d128 significand
// this way we can skip rounding in the constructor a second time
const auto digit_delta {sig_dig - 34};
const auto digit_delta {sig_dig - std::numeric_limits<sig_type>::digits10};
if (BOOST_DECIMAL_LIKELY(digit_delta > 0))
{
res_sig /= pow10<sig_type>(digit_delta);
res_exp += digit_delta;
auto biased_exp {res_exp + detail::bias_v<ReturnType>};
detail::coefficient_rounding<ReturnType>(res_sig, res_exp, biased_exp, sign, sig_dig);
}

BOOST_DECIMAL_ASSERT((res_sig[3] | res_sig[2]) == 0U);
Expand Down
2 changes: 2 additions & 0 deletions test/github_issue_1026.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ int main()
BOOST_TEST_EQ("9999999999999999999999999992345678.49"_DL, "9999999999999999999999999992345678"_DL);
BOOST_TEST_EQ("9999999999999999999999999992345678.50"_DL, "9999999999999999999999999992345678"_DL);
BOOST_TEST_EQ("9999999999999999999999999992345678.51"_DL, "9999999999999999999999999992345679"_DL);
BOOST_TEST_EQ("145433.2908011933696719165119928295655062562131932287426051970822"_DL, "145433.2908011933696719165119928296"_DL);
BOOST_TEST_EQ("30269.587755640502150977251770554"_DL * "4.8046009735990873395936309640543"_DL, "145433.2908011933696719165119928296"_DL);

BOOST_TEST_EQ(("0"_DF + "8.4e-96"_DF), "8.4e-96"_DF);
BOOST_TEST_EQ(("0"_DF + std::numeric_limits<decimal32_t>::denorm_min()), std::numeric_limits<decimal32_t>::denorm_min());
Expand Down
Loading