BAN: Add is_power_of_two to Math functions

This commit is contained in:
Bananymous 2023-04-28 14:42:49 +03:00
parent 5bfcf6783e
commit 88a2c60065
1 changed files with 8 additions and 0 deletions

View File

@ -51,6 +51,14 @@ namespace BAN::Math
return (a + b - 1) / b; return (a + b - 1) / b;
} }
template<integral T>
inline constexpr bool is_power_of_two(T value)
{
if (value == 0)
return false;
return (value & (value - 1)) == 0;
}
template<integral T> template<integral T>
inline constexpr T little_endian_to_host(const uint8_t* bytes) inline constexpr T little_endian_to_host(const uint8_t* bytes)
{ {