Skip to content
Subhajit Sahu edited this page Jun 6, 2020 · 15 revisions

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

Alternatives: [scan], [scanReverse].

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

bit.scan(7);
// 0 (111 => 0)

bit.scan(12);
// 2 (1100 => 2)

bit.scan(64);
// 6 (1000000 => 6)

references

Clone this wiki locally