Skip to content

scanReverse

Subhajit Sahu edited this page Jan 17, 2021 · 7 revisions

Gets index of first set bit from MSB. 🏃 📼 📦 🌔 📒

Alternatives: scan, scanReverse.

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

bit.scanReverse(13);
// 13 (1101 => 3)

bit.scanReverse(5);
// 2 (101 => 2)

bit.scanReverse(1);
// 0 (1 => 0)

references

Clone this wiki locally