Hash_Table module

next_power_of_two

procedureSource

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.

Example↗
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

Parameters

x: int

Returns

int

See also