diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-05-26 22:38:04 +0200 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-05-26 22:38:04 +0200 |
commit | b8a87223bb70fccc47ba0f9c96b3f58de6e1e5bd (patch) | |
tree | 212ad4e788509f9e3c6b2bc41120c8687298dcb4 /asl/base/bit.hpp | |
parent | a1db1cd9e22e77041d5f1360f1d1ccdc52b86306 (diff) |
Diffstat (limited to 'asl/base/bit.hpp')
-rw-r--r-- | asl/base/bit.hpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/asl/base/bit.hpp b/asl/base/bit.hpp index 5056383..824005c 100644 --- a/asl/base/bit.hpp +++ b/asl/base/bit.hpp @@ -114,7 +114,7 @@ constexpr T rotl(T v, int s) // NOLINT(*-no-recursion) { static constexpr int N = sizeof(decltype(v)) * 8; s = s % N; - return (s >= 0) ? (v << s) | (v >> (N - s)) : rotr(v, -s); + return (s >= 0) ? (v << s) | (v >> ((N - s) % N)) : rotr(v, -s); } template<is_unsigned_integer T> @@ -122,7 +122,7 @@ constexpr T rotr(T v, int s) // NOLINT(*-no-recursion) { static constexpr int N = sizeof(decltype(v)) * 8; s = s % N; - return (s >= 0) ? (v >> s) | (v << (N - s)) : rotl(v, -s); + return (s >= 0) ? (v >> s) | (v << ((N - s) % N)) : rotl(v, -s); } constexpr uint16_t byteswap(uint16_t v) |