@@ -1937,21 +1937,15 @@ constexpr auto operator*(decimal128 lhs, decimal128 rhs) noexcept -> decimal128
19371937
19381938 auto lhs_sig {lhs.full_significand ()};
19391939 auto lhs_exp {lhs.biased_exponent ()};
1940-
1941- while (lhs_sig % 10 == 0 && lhs_sig != 0 )
1942- {
1943- lhs_sig /= 10 ;
1944- ++lhs_exp;
1945- }
1940+ const auto lhs_zeros {detail::remove_trailing_zeros (lhs_sig)};
1941+ lhs_sig = lhs_zeros.trimmed_number ;
1942+ lhs_exp += static_cast <std::int32_t >(lhs_zeros.number_of_removed_zeros );
19461943
19471944 auto rhs_sig {rhs.full_significand ()};
19481945 auto rhs_exp {rhs.biased_exponent ()};
1949-
1950- while (rhs_sig % 10 == 0 && rhs_sig != 0 )
1951- {
1952- rhs_sig /= 10 ;
1953- ++rhs_exp;
1954- }
1946+ const auto rhs_zeros {detail::remove_trailing_zeros (rhs_sig)};
1947+ rhs_sig = rhs_zeros.trimmed_number ;
1948+ rhs_exp += static_cast <std::int32_t >(rhs_zeros.number_of_removed_zeros );
19551949
19561950 const auto result {d128_mul_impl (lhs_sig, lhs_exp, lhs.isneg (),
19571951 rhs_sig, rhs_exp, rhs.isneg ())};
@@ -1970,20 +1964,16 @@ constexpr auto operator*(decimal128 lhs, Integer rhs) noexcept
19701964
19711965 auto lhs_sig {lhs.full_significand ()};
19721966 auto lhs_exp {lhs.biased_exponent ()};
1973- while (lhs_sig % 10 == 0 && lhs_sig != 0 )
1974- {
1975- lhs_sig /= 10 ;
1976- ++lhs_exp;
1977- }
1967+ const auto lhs_zeros {detail::remove_trailing_zeros (lhs_sig)};
1968+ lhs_sig = lhs_zeros.trimmed_number ;
1969+ lhs_exp += static_cast <std::int32_t >(lhs_zeros.number_of_removed_zeros );
19781970 auto lhs_components {detail::decimal128_components{lhs_sig, lhs_exp, lhs.isneg ()}};
19791971
19801972 auto rhs_sig {static_cast <detail::uint128>(detail::make_positive_unsigned (rhs))};
19811973 std::int32_t rhs_exp {0 };
1982- while (rhs_sig % 10 == 0 && rhs_sig != 0 )
1983- {
1984- rhs_sig /= 10 ;
1985- ++rhs_exp;
1986- }
1974+ const auto rhs_zeros {detail::remove_trailing_zeros (rhs_sig)};
1975+ rhs_sig = rhs_zeros.trimmed_number ;
1976+ rhs_exp += static_cast <std::int32_t >(rhs_zeros.number_of_removed_zeros );
19871977 auto unsigned_sig_rhs {detail::make_positive_unsigned (rhs_sig)};
19881978 auto rhs_components {detail::decimal128_components{unsigned_sig_rhs, rhs_exp, (rhs < 0 )}};
19891979
@@ -2433,25 +2423,18 @@ constexpr auto fmad128(decimal128 x, decimal128 y, decimal128 z) noexcept -> dec
24332423
24342424 auto sig_lhs {x.full_significand ()};
24352425 auto exp_lhs {x.biased_exponent ()};
2436-
2437- while (sig_lhs % 10 == 0 && sig_lhs != 0 )
2438- {
2439- sig_lhs /= 10 ;
2440- ++exp_lhs;
2441- }
2426+ detail::normalize<decimal128>(sig_lhs, exp_lhs);
24422427
24432428 auto sig_rhs {y.full_significand ()};
24442429 auto exp_rhs {y.biased_exponent ()};
2445-
2446- while (sig_rhs % 10 == 0 && sig_rhs != 0 )
2447- {
2448- sig_rhs /= 10 ;
2449- ++exp_rhs;
2450- }
2430+ detail::normalize<decimal128>(sig_rhs, exp_rhs);
24512431
24522432 auto mul_result {d128_mul_impl (sig_lhs, exp_lhs, x.isneg (), sig_rhs, exp_rhs, y.isneg ())};
24532433 const decimal128 dec_result {mul_result.sig , mul_result.exp , mul_result.sign };
24542434
2435+ return dec_result + z;
2436+
2437+ /*
24552438 const auto res_add {detail::check_non_finite(dec_result, z)};
24562439 if (res_add != zero)
24572440 {
@@ -2493,6 +2476,7 @@ constexpr auto fmad128(decimal128 x, decimal128 y, decimal128 z) noexcept -> dec
24932476 }
24942477
24952478 return {result.sig, result.exp, result.sign};
2479+ */
24962480}
24972481
24982482} // namespace decimal
0 commit comments