Skip to content

Commit 556518d

Browse files
committed
Fix case of differing signs
1 parent 7946a42 commit 556518d

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
@@ -122,7 +122,7 @@ constexpr auto add_impl(const T& lhs, const T& rhs) noexcept -> ReturnType
122122
{
123123
if (big_rhs != 0U)
124124
{
125-
if (lhs.isneg())
125+
if (lhs.isneg() != rhs.isneg())
126126
{
127127
if (is_power_of_10(big_lhs))
128128
{
@@ -148,7 +148,7 @@ constexpr auto add_impl(const T& lhs, const T& rhs) noexcept -> ReturnType
148148
{
149149
if (big_lhs != 0U)
150150
{
151-
if (rhs.isneg())
151+
if (rhs.isneg() != lhs.isneg())
152152
{
153153
--big_rhs;
154154
big_rhs *= 10U;
@@ -282,7 +282,7 @@ constexpr auto d128_add_impl(T lhs_sig, U lhs_exp, bool lhs_sign,
282282
{
283283
if (rhs_sig != 0U)
284284
{
285-
if (lhs_sign)
285+
if (lhs_sign != rhs_sign)
286286
{
287287
if (is_power_of_10(lhs_sig))
288288
{
@@ -308,7 +308,7 @@ constexpr auto d128_add_impl(T lhs_sig, U lhs_exp, bool lhs_sign,
308308
{
309309
if (lhs_sig != 0U)
310310
{
311-
if (rhs_sign)
311+
if (rhs_sign != lhs_sign)
312312
{
313313
--rhs_sig;
314314
rhs_sig *= 10U;

0 commit comments

Comments
 (0)