diff options
author | David Robillard <d@drobilla.net> | 2022-09-16 16:27:19 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-09-16 22:31:06 -0400 |
commit | 8697e134aeac0318e6686d785113f0763cbc3c1c (patch) | |
tree | 86897017d682939a1faf586b5bb61a15f814387a /include/chilbert/detail | |
parent | 49dab5622b31421eb6af84eae376d73fae1cd4a0 (diff) | |
download | chilbert-8697e134aeac0318e6686d785113f0763cbc3c1c.tar.gz chilbert-8697e134aeac0318e6686d785113f0763cbc3c1c.tar.bz2 chilbert-8697e134aeac0318e6686d785113f0763cbc3c1c.zip |
Fix signed bitwise operator operands
Diffstat (limited to 'include/chilbert/detail')
-rw-r--r-- | include/chilbert/detail/BitVecMask.hpp | 8 | ||||
-rw-r--r-- | include/chilbert/detail/MultiBitVec.hpp | 6 | ||||
-rw-r--r-- | include/chilbert/detail/operations.hpp | 4 |
3 files changed, 9 insertions, 9 deletions
diff --git a/include/chilbert/detail/BitVecMask.hpp b/include/chilbert/detail/BitVecMask.hpp index 03eaf5f..2d3466a 100644 --- a/include/chilbert/detail/BitVecMask.hpp +++ b/include/chilbert/detail/BitVecMask.hpp @@ -43,16 +43,16 @@ struct BitVecMask void operator++() { - if ((mask <<= 1) == 0) { - mask = 1; + if ((mask <<= 1U) == 0U) { + mask = 1U; ++rack; } } void operator--() { - if ((mask >>= 1) == 0) { - mask = Rack{1} << (bits_per_rack - 1); + if ((mask >>= 1U) == 0U) { + mask = Rack{1} << (bits_per_rack - 1U); --rack; } } diff --git a/include/chilbert/detail/MultiBitVec.hpp b/include/chilbert/detail/MultiBitVec.hpp index 573deef..2896c7c 100644 --- a/include/chilbert/detail/MultiBitVec.hpp +++ b/include/chilbert/detail/MultiBitVec.hpp @@ -354,9 +354,9 @@ gray_code(MultiBitVec<Derived>& value) constexpr size_t left_shift = MultiBitVec<Derived>::bits_per_rack - 1; for (size_t ri = 0; ri < value.num_racks(); ++ri) { - const size_t i = value.num_racks() - ri - 1; + const size_t i = value.num_racks() - ri - 1U; auto& rack = value.rack(i); - const auto t = rack & 1; + const auto t = rack & 1U; gray_code(rack); rack ^= (s << left_shift); s = t; @@ -377,7 +377,7 @@ gray_code_inv(MultiBitVec<Derived>& value) auto& rack = value.rack(i); gray_code_inv(rack); rack ^= masks[s]; - s = rack & 1; + s = rack & 1U; } } diff --git a/include/chilbert/detail/operations.hpp b/include/chilbert/detail/operations.hpp index 7e846b3..398944f 100644 --- a/include/chilbert/detail/operations.hpp +++ b/include/chilbert/detail/operations.hpp @@ -145,7 +145,7 @@ template <typename T> std::enable_if_t<std::is_integral<T>::value> gray_code(T& value) { - value ^= (value >> 1); + value ^= (value >> 1U); } /// Calculates the inverse Gray Code of `value` in place @@ -158,7 +158,7 @@ std::enable_if_t<std::is_integral<T>::value> gray_code_inv(T& value) { constexpr T shift_end = sizeof(T) * CHAR_BIT; - for (T shift = 1; shift < shift_end; shift <<= 1) { + for (T shift = 1U; shift < shift_end; shift <<= 1U) { value ^= (value >> shift); } } |