The smallest power of two that is at least x, and 1 for anything below that. Fails an assert when the result would not fit an int.
assert(next_power_of_two(33) == 64);
assert(next_power_of_two(64) == 64);
assert(next_power_of_two(0) == 1);next_power_of_two :: (x: int) -> int
The smallest power of two that is at least x, and 1 for anything below that. Fails an assert when the result would not fit an int.
Parameters
- x: int
Returns
- int
assert(next_power_of_two(33) == 64);
assert(next_power_of_two(64) == 64);
assert(next_power_of_two(0) == 1);