Skip to content

Commit 953271a

Browse files
committed
Re-add lost condition
1 parent 28a8554 commit 953271a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

include/boost/decimal/detail/add_impl.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ constexpr auto add_impl(const T& lhs, const T& rhs) noexcept -> ReturnType
7474
// Need to check for the case where we have 1e+95 - anything = 9.99999... without losing a nine
7575
if (use_lhs)
7676
{
77-
if (big_rhs != 0U)
77+
if (big_rhs != 0U && (lhs.isneg() != rhs.isneg()))
7878
{
7979
const auto removed_zeros {detail::remove_trailing_zeros(big_lhs)};
8080
if (removed_zeros.trimmed_number == 1U)
@@ -94,7 +94,7 @@ constexpr auto add_impl(const T& lhs, const T& rhs) noexcept -> ReturnType
9494
}
9595
else
9696
{
97-
if (big_lhs != 0U)
97+
if (big_lhs != 0U && (lhs.isneg() != rhs.isneg()))
9898
{
9999
const auto removed_zeros {detail::remove_trailing_zeros(big_rhs)};
100100
if (removed_zeros.trimmed_number == 1U)
@@ -192,7 +192,7 @@ constexpr auto d128_add_impl(T lhs_sig, U lhs_exp, bool lhs_sign,
192192
// Need to check for the case where we have 1e+95 - anything = 9.99999... without losing a nine
193193
if (use_lhs)
194194
{
195-
if (rhs_sig != 0U)
195+
if (rhs_sig != 0U && (lhs_sign != rhs_sign))
196196
{
197197
const auto removed_zeros {detail::remove_trailing_zeros(lhs_sig)};
198198
if (removed_zeros.trimmed_number == 1U)
@@ -212,7 +212,7 @@ constexpr auto d128_add_impl(T lhs_sig, U lhs_exp, bool lhs_sign,
212212
}
213213
else
214214
{
215-
if (lhs_sig != 0U)
215+
if (lhs_sig != 0U && (lhs_sign != rhs_sign))
216216
{
217217
const auto removed_zeros {detail::remove_trailing_zeros(rhs_sig)};
218218
if (removed_zeros.trimmed_number == 1U)

0 commit comments

Comments
 (0)