Skip to content

Commit 8bf490c

Browse files
committed
Use existing mul impl
1 parent 445839d commit 8bf490c

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

include/boost/decimal/decimal_fast32_t.hpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final
121121
template <typename ReturnType, typename T>
122122
friend constexpr auto detail::add_impl(const T& lhs, const T& rhs) noexcept -> ReturnType;
123123

124+
template <typename ReturnType, typename T>
125+
friend constexpr auto detail::mul_impl(const T& lhs, const T& rhs) noexcept -> ReturnType;
126+
124127
template <BOOST_DECIMAL_FAST_DECIMAL_FLOATING_TYPE DecimalType>
125128
BOOST_DECIMAL_FORCE_INLINE friend constexpr auto fast_equality_impl(const DecimalType& lhs, const DecimalType& rhs) noexcept -> bool;
126129

@@ -902,26 +905,7 @@ constexpr auto operator*(const decimal_fast32_t lhs, const decimal_fast32_t rhs)
902905
}
903906
#endif
904907

905-
using mul_type = std::uint_fast64_t;
906-
907-
const auto isneg {lhs.sign_ != rhs.sign_};
908-
constexpr auto ten_pow_seven {detail::pow10(static_cast<mul_type>(6))};
909-
constexpr auto ten_pow_seven_exp_offset {95};
910-
constexpr auto ten_pow_six {detail::pow10(static_cast<mul_type>(5))};
911-
constexpr auto ten_pow_six_exp_offset {96};
912-
913-
auto res_sig {(static_cast<mul_type>(lhs.significand_) * static_cast<mul_type>(rhs.significand_))};
914-
const bool res_sig_14_dig {res_sig > UINT64_C(10000000000000)};
915-
res_sig /= res_sig_14_dig ? ten_pow_seven : ten_pow_six;
916-
auto res_exp {lhs.exponent_ + rhs.exponent_};
917-
res_exp -= res_sig_14_dig ? ten_pow_seven_exp_offset : ten_pow_six_exp_offset;
918-
919-
res_exp += detail::fenv_round<decimal_fast32_t>(res_sig, isneg);
920-
921-
BOOST_DECIMAL_ASSERT(res_sig >= 1'000'000 || res_sig == 0U);
922-
BOOST_DECIMAL_ASSERT(res_exp <= 9'999'999 || res_sig == 0U);
923-
924-
return direct_init(static_cast<decimal_fast32_t::significand_type>(res_sig), static_cast<decimal_fast32_t::exponent_type>(res_exp) , isneg);
908+
return detail::mul_impl<decimal_fast32_t>(lhs, rhs);
925909
}
926910

927911
template <typename Integer>

0 commit comments

Comments
 (0)