Skip to content

Commit

Permalink
Simplify implementation of operator~
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed May 17, 2022
1 parent e556120 commit 48d2aec
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions include/intx/intx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,14 @@ struct uint
inline constexpr uint& operator%=(const uint& y) noexcept { return *this = *this % y; }


inline constexpr uint operator~() const noexcept
{
uint z;
for (size_t i = 0; i < num_words; ++i)
z[i] = ~words_[i];
return z;
}

friend inline constexpr uint operator|(const uint& x, const uint& y) noexcept
{
uint z;
Expand Down Expand Up @@ -1313,15 +1321,6 @@ inline constexpr bool slt(const uint<N>& x, const uint<N>& y) noexcept
return ((x_neg ^ y_neg) != 0) ? x_neg : x < y;
}

template <unsigned N>
inline constexpr uint<N> operator~(const uint<N>& x) noexcept
{
uint<N> z;
for (size_t i = 0; i < uint<N>::num_words; ++i)
z[i] = ~x[i];
return z;
}


inline constexpr uint256 operator<<(const uint256& x, uint64_t shift) noexcept
{
Expand Down

0 comments on commit 48d2aec

Please sign in to comment.