Skip to content
Subhajit Sahu edited this page Feb 2, 2021 · 15 revisions

Get bits as per mask. 📦 😺 🏃 📼 🌔 📜 📰 📘

Alternatives: get, getAs.
Similar: get, set, toggle.


bit.getAs(x, m);
// x: an int32
// m: bit mask
const bit = require("extra-bit");

bit.getAs(6, 4);
// 4 (110,100 ⇒ 100)

bit.getAs(6, 7);
// 6 (110,111 ⇒ 110)

bit.getAs(6, 5);
// 4 (110,101 ⇒ 100)


References

Clone this wiki locally