Skip to content

scanReverse

Subhajit Sahu edited this page Jul 25, 2022 · 13 revisions

Find index of first set bit from MSB.

Alternatives: scan, scanReverse.


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

xbit.scanReverse(13);
// → 13 (1101 ⇒ 3)

xbit.scanReverse(5);
// → 2 (101 ⇒ 2)

xbit.scanReverse(1);
// → 0 (1 ⇒ 0)


References

Clone this wiki locally