Skip to content

Commit f6fa637

Browse files
committed
Change division type for old clangs
1 parent cdf9ffa commit f6fa637

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

include/boost/decimal/decimal64_fast.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,9 @@ template <typename Integer>
12271227
constexpr auto operator/(decimal64_fast lhs, Integer rhs) noexcept
12281228
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_integral_v, Integer, decimal64_fast)
12291229
{
1230+
using promoted_significand_type = detail::promote_significand_t<decimal64_fast, Integer>;
1231+
using exp_type = detail::decimal64_fast_components::biased_exponent_type;
1232+
12301233
#ifndef BOOST_DECIMAL_FAST_MATH
12311234
// Check pre-conditions
12321235
constexpr decimal64_fast zero {0, 0};
@@ -1261,8 +1264,8 @@ constexpr auto operator/(decimal64_fast lhs, Integer rhs) noexcept
12611264

12621265
detail::decimal64_fast_components lhs_components {lhs_sig, lhs_exp, lhs.isneg()};
12631266

1264-
auto rhs_sig {static_cast<decimal64_fast::significand_type>(detail::make_positive_unsigned(rhs))};
1265-
std::int32_t rhs_exp {};
1267+
auto rhs_sig {static_cast<promoted_significand_type>(detail::make_positive_unsigned(rhs))};
1268+
exp_type rhs_exp {};
12661269
detail::decimal64_fast_components rhs_components {detail::shrink_significand<decimal64_fast::significand_type>(rhs_sig, rhs_exp), rhs_exp, rhs < 0};
12671270

12681271
return detail::d64_generic_div_impl<decimal64_fast>(lhs_components, rhs_components);
@@ -1272,6 +1275,9 @@ template <typename Integer>
12721275
constexpr auto operator/(Integer lhs, decimal64_fast rhs) noexcept
12731276
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_integral_v, Integer, decimal64_fast)
12741277
{
1278+
using promoted_significand_type = detail::promote_significand_t<decimal64_fast, Integer>;
1279+
using exp_type = detail::decimal64_fast_components::biased_exponent_type;
1280+
12751281
#ifndef BOOST_DECIMAL_FAST_MATH
12761282
// Check pre-conditions
12771283
constexpr decimal64_fast zero {0, 0};
@@ -1301,10 +1307,12 @@ constexpr auto operator/(Integer lhs, decimal64_fast rhs) noexcept
13011307
auto rhs_sig {rhs.full_significand()};
13021308
auto rhs_exp {rhs.biased_exponent()};
13031309
detail::normalize<decimal64>(rhs_sig, rhs_exp);
1304-
1305-
detail::decimal64_fast_components lhs_components {detail::make_positive_unsigned(lhs), 0, lhs < 0};
13061310
detail::decimal64_fast_components rhs_components {rhs_sig, rhs_exp, rhs.isneg()};
13071311

1312+
auto lhs_sig {static_cast<promoted_significand_type>(detail::make_positive_unsigned(lhs))};
1313+
exp_type lhs_exp {};
1314+
detail::decimal64_fast_components lhs_components {detail::shrink_significand<decimal64_fast::significand_type>(lhs_sig, lhs_exp), lhs_exp, lhs < 0};
1315+
13081316
return detail::d64_generic_div_impl<decimal64_fast>(lhs_components, rhs_components);
13091317
}
13101318

include/boost/decimal/detail/div_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ BOOST_DECIMAL_FORCE_INLINE constexpr auto generic_div_impl(const T& lhs, const T
4545
template <typename DecimalType, typename T>
4646
constexpr auto d64_generic_div_impl(const T& lhs, const T& rhs) noexcept -> DecimalType
4747
{
48-
#ifdef BOOST_DECIMAL_HAS_INT128
48+
#if defined(BOOST_DECIMAL_HAS_INT128) && (!defined(__clang_major__) || __clang_major__ > 13)
4949
using unsigned_int128_type = boost::decimal::detail::uint128_t;
5050
#else
5151
using unsigned_int128_type = boost::decimal::detail::uint128;

0 commit comments

Comments
 (0)