Skip to content

Commit 0b94018

Browse files
committed
Use new impl for mixed type arithmetic
1 parent e21835a commit 0b94018

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

include/boost/decimal/decimal32.hpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -973,11 +973,6 @@ constexpr auto operator-(decimal32 lhs, Integer rhs) noexcept
973973
}
974974
#endif
975975

976-
if (!lhs.isneg() && (rhs < 0))
977-
{
978-
return lhs + detail::make_positive_unsigned(rhs);
979-
}
980-
981976
auto sig_rhs {static_cast<promoted_significand_type>(detail::make_positive_unsigned(rhs))};
982977
const bool abs_lhs_bigger {abs(lhs) > sig_rhs};
983978

@@ -989,9 +984,9 @@ constexpr auto operator-(decimal32 lhs, Integer rhs) noexcept
989984
detail::normalize(sig_rhs, exp_rhs);
990985
auto final_sig_rhs {static_cast<decimal32::significand_type>(sig_rhs)};
991986

992-
return detail::sub_impl<decimal32>(sig_lhs, exp_lhs, lhs.isneg(),
993-
final_sig_rhs, exp_rhs, (rhs < 0),
994-
abs_lhs_bigger);
987+
return detail::new_sub_impl<decimal32>(sig_lhs, exp_lhs, lhs.isneg(),
988+
final_sig_rhs, exp_rhs, (rhs < 0),
989+
abs_lhs_bigger);
995990
}
996991

997992
template <typename Integer>
@@ -1007,12 +1002,7 @@ constexpr auto operator-(Integer lhs, decimal32 rhs) noexcept
10071002
return rhs;
10081003
}
10091004
#endif
1010-
1011-
if (lhs >= 0 && rhs.isneg())
1012-
{
1013-
return lhs + (-rhs);
1014-
}
1015-
1005+
10161006
auto sig_lhs {static_cast<promoted_significand_type>(detail::make_positive_unsigned(lhs))};
10171007
const bool abs_lhs_bigger {sig_lhs > abs(rhs)};
10181008

@@ -1024,9 +1014,9 @@ constexpr auto operator-(Integer lhs, decimal32 rhs) noexcept
10241014
auto exp_rhs {rhs.biased_exponent()};
10251015
detail::normalize(sig_rhs, exp_rhs);
10261016

1027-
return detail::sub_impl<decimal32>(final_sig_lhs, exp_lhs, (lhs < 0),
1028-
sig_rhs, exp_rhs, rhs.isneg(),
1029-
abs_lhs_bigger);
1017+
return detail::new_sub_impl<decimal32>(final_sig_lhs, exp_lhs, (lhs < 0),
1018+
sig_rhs, exp_rhs, rhs.isneg(),
1019+
abs_lhs_bigger);
10301020
}
10311021

10321022
constexpr auto decimal32::operator--() noexcept -> decimal32&

0 commit comments

Comments
 (0)