nextPowerOfTwo
Computes the next power-of-two integer greater than or equal to the provided non-negative integer. The maximum allowed input is 2^31 due to 32-bit bitwise operator limitation in Javascript.
const n = Math.nextPowerOfTwo(29); // 32
const m = Math.nextPowerOfTwo(32); // 32
Content copied to clipboard
Return
The next power-of-two integer.
Parameters
n
The integer to test in the range 0, 2^31.