-
Notifications
You must be signed in to change notification settings - Fork 1
setAs
Subhajit Sahu edited this page Feb 2, 2021
·
15 revisions
Set bits as per mask. 📦 😺 🏃 📼 🌔 📜 📰 📘
bit.setAs(x, m, [f]);
// x: an int32
// m: bit mask
// f: bit value (1)
const bit = require("extra-bit");
bit.setAs(8, 2, 1);
// 10 (0x8 set 0x2 ⇒ 0xA)
bit.setAs(15, 3, 0);
// 12 (0xF clear 0x3 ⇒ 0xC)
bit.setAs(0x1234, 0x430, 1);
// 5684 (0x1234 set 0x430 ⇒ 0x1634)