@@ -128,7 +128,7 @@ constexpr auto d64_sub_impl(T lhs_sig, U lhs_exp, bool lhs_sign,
128128
129129 if (delta_exp > 1 )
130130 {
131- sig_smaller /= pow10<std:: remove_reference_t < decltype (sig_smaller)> >(delta_exp - 1 );
131+ sig_smaller /= pow10<sub_type >(delta_exp - 1 );
132132 delta_exp = 1 ;
133133 }
134134
@@ -140,8 +140,7 @@ constexpr auto d64_sub_impl(T lhs_sig, U lhs_exp, bool lhs_sign,
140140
141141 // Both of the significands are less than 9'999'999'999'999'999, so we can safely
142142 // cast them to signed 64-bit ints to calculate the new significand
143- const sub_type new_sig {rhs_sign && !lhs_sign ? signed_sig_lhs + signed_sig_rhs :
144- signed_sig_lhs - signed_sig_rhs};
143+ const auto new_sig {signed_sig_lhs - signed_sig_rhs};
145144
146145 const auto new_exp {abs_lhs_bigger ? lhs_exp : rhs_exp};
147146 const auto new_sign {new_sig < 0 };
@@ -150,10 +149,9 @@ constexpr auto d64_sub_impl(T lhs_sig, U lhs_exp, bool lhs_sign,
150149 return {res_sig, new_exp, new_sign};
151150}
152151
153- template <typename ReturnType, BOOST_DECIMAL_INTEGRAL T1, BOOST_DECIMAL_INTEGRAL U1,
154- BOOST_DECIMAL_INTEGRAL T2, BOOST_DECIMAL_INTEGRAL U2>
155- constexpr auto d128_sub_impl (T1 lhs_sig, U1 lhs_exp, bool lhs_sign,
156- T2 rhs_sig, U2 rhs_exp, bool rhs_sign,
152+ template <typename ReturnType, BOOST_DECIMAL_INTEGRAL T, BOOST_DECIMAL_INTEGRAL U>
153+ constexpr auto d128_sub_impl (T lhs_sig, U lhs_exp, bool lhs_sign,
154+ T rhs_sig, U rhs_exp, bool rhs_sign,
157155 bool abs_lhs_bigger) noexcept -> ReturnType
158156{
159157 #if defined(BOOST_DECIMAL_HAS_INT128) && (!defined(__clang_major__) || __clang_major__ > 13)
@@ -172,8 +170,8 @@ constexpr auto d128_sub_impl(T1 lhs_sig, U1 lhs_exp, bool lhs_sign,
172170 // we return the larger of the two
173171 //
174172 // e.g. 1e20 - 1e-20 = 1e20
175- return abs_lhs_bigger ? ReturnType{detail::shrink_significand<detail::uint128>( lhs_sig, lhs_exp) , lhs_exp, false } :
176- ReturnType{detail::shrink_significand<detail::uint128>( rhs_sig, rhs_exp) , rhs_exp, true };
173+ return abs_lhs_bigger ? ReturnType{lhs_sig, lhs_exp, false } :
174+ ReturnType{rhs_sig, rhs_exp, true };
177175 }
178176
179177 // The two numbers can be subtracted together without special handling
@@ -213,7 +211,7 @@ constexpr auto d128_sub_impl(T1 lhs_sig, U1 lhs_exp, bool lhs_sign,
213211 const auto signed_sig_lhs {detail::make_signed_value (static_cast <unsigned_sub_type>(lhs_sig), lhs_sign)};
214212 const auto signed_sig_rhs {detail::make_signed_value (static_cast <unsigned_sub_type>(rhs_sig), rhs_sign)};
215213
216- const auto new_sig {rhs_sign && !lhs_sign ? signed_sig_lhs + signed_sig_rhs : signed_sig_lhs - signed_sig_rhs};
214+ const auto new_sig {signed_sig_lhs - signed_sig_rhs};
217215
218216 const auto new_exp {abs_lhs_bigger ? lhs_exp : rhs_exp};
219217 const auto new_sign {new_sig < 0 };
0 commit comments