isPow2 - nodef/extra-bigint GitHub Wiki

Check if bigint is a power-of-2.

Similar: isPow2, isPow10. Similar: isPow2, prevPow2, nextPow2.

function isPow2(x)
// x: a bigint
const xbigint = require('extra-bigint');


xbigint.isPow2(32n);
// → true

xbigint.isPow2(1023n);
// → false

References