[math_utils] Add is_power_of_two()
This commit is contained in:
parent
5260a87c0b
commit
a345b894d3
@ -34,6 +34,11 @@ namespace base {
|
|||||||
T div_down(T const &v, T const &divisor) {
|
T div_down(T const &v, T const &divisor) {
|
||||||
return v / divisor;
|
return v / divisor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool is_power_of_two(T const v) {
|
||||||
|
return !(v & (v - 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user