SDEngine
Game Engine
Loading...
Searching...
No Matches
math_utils.hpp
Go to the documentation of this file.
1#pragma once
2namespace sd {
3
8namespace math {
9// TODO(docs): Document log2_int - explain use case, constraints (what happens with 0)
10consteval usize log2_int(std::unsigned_integral auto n) {
11 // log2(n) = bit_width(n) - 1
12 return n == 0 ? 0 : std::bit_width(n) - 1;
13}
14} // namespace math
15
16
17} // namespace sd
Math utilities.
consteval usize log2_int(std::unsigned_integral auto n)
Definition math_utils.hpp:10
Definition Application.hpp:28
constexpr T g_type_max
Definition types.hpp:21
std::size_t usize
Definition types.hpp:18