-
Notifications
You must be signed in to change notification settings - Fork 1
setAs
Subhajit Sahu edited this page Jul 25, 2022
·
15 revisions
Set bits as per mask.
setAs(x, m, [f])
// x: an int32
// m: bit mask
// f: bit value (1)
const xbit = require('extra-bit');
xbit.setAs(8, 2, 1);
// → 10 (0x8 set 0x2 ⇒ 0xA)
xbit.setAs(15, 3, 0);
// → 12 (0xF clear 0x3 ⇒ 0xC)
xbit.setAs(0x1234, 0x430, 1);
// → 5684 (0x1234 set 0x430 ⇒ 0x1634)