isPowerOfTwo
Determines if a non-negative integer is a power of two. The maximum allowed input is (2^32)-1 due to 32-bit bitwise operator limitation in Javascript.
const t = Math.isPowerOfTwo(16); // true
const f = Math.isPowerOfTwo(20); // falseContent copied to clipboard
Return
true if the number if a power of two; otherwise, false.
Parameters
n
The integer to test in the range 0, (2^32)-1.