M5Utility 0.0.2 git rev:5c1a751
Loading...
Searching...
No Matches
math.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
10#ifndef M5_UTILITY_MATH_HPP
11#define M5_UTILITY_MATH_HPP
12
13#include <cstdint>
14#include <type_traits>
15
16namespace m5 {
17namespace math {
18template <typename T>
19
26inline constexpr bool is_powerof2(const T v)
27{
28 static_assert(std::is_integral<T>::value, "The argument v is only an integer value.");
29 return v > 0 && ((v & (v - 1)) == 0);
30}
31
32} // namespace math
33} // namespace m5
34#endif
constexpr bool is_powerof2(const T v)
Is value power of 2?
Definition math.hpp:26
Top level namespace of M5.
Definition bit_segment.hpp:17