@@ -147,6 +147,9 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final
147147 template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
148148 friend constexpr auto detail::to_chars_hex_impl (char * first, char * last, const TargetDecimalType& value) noexcept -> to_chars_result;
149149
150+ template <typename DecimalType, typename T>
151+ friend constexpr auto detail::generic_div_impl (const T& lhs, const T& rhs) noexcept -> DecimalType;
152+
150153public:
151154 constexpr decimal_fast32_t () noexcept = default;
152155
@@ -985,43 +988,7 @@ constexpr auto div_impl(const decimal_fast32_t lhs, const decimal_fast32_t rhs,
985988 static_cast <void >(r);
986989 #endif
987990
988- #ifdef BOOST_DECIMAL_DEBUG
989- std::cerr << " sig lhs: " << sig_lhs
990- << " \n exp lhs: " << exp_lhs
991- << " \n sig rhs: " << sig_rhs
992- << " \n exp rhs: " << exp_rhs << std::endl;
993- #endif
994-
995- using local_signed_exponent_type = std::common_type_t <std::int_fast32_t , int >;
996-
997- static_assert (sizeof (local_signed_exponent_type) >= 4 , " Error in local exponent type definition" );
998-
999- // We promote to uint64 since the significands are currently 32-bits
1000- // By appending enough zeros to the LHS we end up finding what we need anyway
1001- constexpr auto ten_pow_precision {detail::pow10 (static_cast <std::uint_fast64_t >(detail::precision_v<decimal32_t >))};
1002- const auto big_sig_lhs {static_cast <std::uint_fast64_t >(lhs.significand_ ) * ten_pow_precision};
1003- auto res_sig {big_sig_lhs / static_cast <std::uint_fast64_t >(rhs.significand_ )};
1004- local_signed_exponent_type res_exp {static_cast <local_signed_exponent_type>(lhs.exponent_ ) - static_cast <local_signed_exponent_type>(rhs.exponent_ ) + 94 };
1005- const auto isneg {lhs.sign_ != rhs.sign_ };
1006-
1007- // If we have 8 figures round it down to 7
1008- if (res_sig >= UINT64_C (10'000'000 ))
1009- {
1010- res_exp += detail::fenv_round<decimal_fast32_t >(res_sig, isneg);
1011- }
1012-
1013- BOOST_DECIMAL_ASSERT (res_sig >= 1'000'000 || res_sig == 0U );
1014- BOOST_DECIMAL_ASSERT (res_exp <= 9'999'999 || res_sig == 0U );
1015-
1016- if (BOOST_DECIMAL_LIKELY (res_exp >= 0 ))
1017- {
1018- q = direct_init (static_cast <decimal_fast32_t ::significand_type>(res_sig), static_cast <decimal_fast32_t ::exponent_type>(res_exp), isneg);
1019- }
1020- else
1021- {
1022- // Flush to zero
1023- q = zero;
1024- }
991+ q = detail::generic_div_impl<decimal_fast32_t >(lhs, rhs);
1025992}
1026993
1027994constexpr auto mod_impl (const decimal_fast32_t lhs, const decimal_fast32_t rhs, const decimal_fast32_t & q, decimal_fast32_t & r) noexcept -> void
0 commit comments