tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
rotl.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: BSL-1.0
2
3
#ifndef TETL_BIT_ROTL_HPP
4
#define TETL_BIT_ROTL_HPP
5
6
#include <
etl/_concepts/builtin_unsigned_integer.hpp
>
7
#include <
etl/_limits/numeric_limits.hpp
>
8
9
namespace
etl
{
10
15
template
<etl::builtin_
unsigned
_
int
eger UInt>
16
constexpr
auto
rotl
(UInt t,
int
s)
noexcept
-> UInt
17
{
18
auto
const
c =
static_cast<
unsigned
>
(s);
19
auto
const
d =
static_cast<
unsigned
>
(
etl::numeric_limits<UInt>::digits
);
20
if
((c % d) == 0U) {
21
return
t;
22
}
23
return
static_cast<
UInt
>
((t << (c % d)) | (t >> (d - (c % d))));
24
}
25
26
}
// namespace etl
27
28
#endif
// TETL_BIT_ROTL_HPP
builtin_unsigned_integer.hpp
etl::rotl
constexpr auto rotl(UInt t, int s) noexcept -> UInt
Computes the result of bitwise left-rotating the value of x by s positions. This operation is also kn...
Definition
rotl.hpp:16
etl
Definition
adjacent_find.hpp:8
numeric_limits.hpp
etl::numeric_limits::digits
static constexpr int digits
Definition
numeric_limits.hpp:24
include
etl
_bit
rotl.hpp
Generated on Sat Mar 8 2025 16:19:59 for tetl by
1.14.0