Skip to content

nextPow2

Subhajit Sahu edited this page Aug 9, 2022 · 1 revision

Find smallest power-of-2 greater than or equal to given bigint.

Similar: nextPow2, nextPow10.
Similar: isPow2, prevPow2, nextPow2.


function nextPow2(x)
// x: a bigint

const xbigint = require('extra-bigint');


xbigint.nextPow2(32n);
// → 32n

xbigint.nextPow2(1023n);
// → 1024n


References

Clone this wiki locally