Skip to content

scanReverse

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

Get index of first set bit from MSB. 📰 📘

Alternatives: scan, scanReverse.


Bit.scanReverse(x);
// x: an int or long
import io.github.javaf.*;

Bit.scanReverse(13);
// 13 (1101 ⇒ 3)

Bit.scanReverse(5);
// 2 (101 ⇒ 2)

Bit.scanReverse(1);
// 0 (1 ⇒ 0)


References

Clone this wiki locally