Skip to content

Commit 2766944

Browse files
authored
Change unary minus operator implementation
Make unary minus operator to be available in constant expressions.
1 parent bec41f2 commit 2766944

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

include/long_uint.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,12 @@ constexpr long_uint_t<native_t, size> long_uint_t<native_t, size>::operator-() c
551551
for (uint_t n = 0; n < std::size(digits); ++n)
552552
negative.digits[n] = ~digits[n];
553553

554-
return ++negative;
554+
bool carry = true;
555+
556+
for (uint_t n = 0; n < std::size(negative.digits); ++n)
557+
negative.digits[n] = addc<native_t>(negative.digits[n], 0, carry);
558+
559+
return negative;
555560
}
556561

557562

0 commit comments

Comments
 (0)