Skip to content
Subhajit Sahu edited this page Aug 1, 2022 · 17 revisions

Checks if value is a power-of-2.

Similar: log2, pow2, isPow2, nextPow2, prevPow2.


isPow2(x)
// x: an int32

const xinteger = require('extra-integer');


xinteger.isPow2(1024);
// → true

xinteger.isPow2(63);
// → false

xinteger.isPow2(1);
// → true


References

Clone this wiki locally