tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
rotr.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_BIT_ROTR_HPP
4#define TETL_BIT_ROTR_HPP
5
8
9namespace etl {
10
15template <etl::builtin_unsigned_integer UInt>
16constexpr auto rotr(UInt t, int s) noexcept -> UInt
17{
18 auto const cnt = static_cast<unsigned>(s);
19 auto const digits = static_cast<unsigned>(etl::numeric_limits<UInt>::digits);
20 if ((cnt % digits) == 0) {
21 return t;
22 }
23 return static_cast<UInt>((t >> (cnt % digits)) | (t << (digits - (cnt % digits))));
24}
25
26} // namespace etl
27
28#endif // TETL_BIT_ROTR_HPP
constexpr auto rotr(UInt t, int s) noexcept -> UInt
Computes the result of bitwise right-rotating the value of x by s positions. This operation is also k...
Definition rotr.hpp:16
Definition adjacent_find.hpp:8
static constexpr int digits
Definition numeric_limits.hpp:24