scan - nodef/extra-bit GitHub Wiki

Find index of first set bit from LSB.

Alternatives: scan, scanReverse.

scan(x)
// x: an int32
const xbit = require('extra-bit');

xbit.scan(7);
// → 0 (111 ⇒ 0)

xbit.scan(12);
// → 2 (1100 ⇒ 2)

xbit.scan(64);
// → 6 (1000000 ⇒ 6)

References