-
Notifications
You must be signed in to change notification settings - Fork 1
setAs
wolfram77 edited this page Apr 1, 2020
·
15 revisions
Sets bits as per mask (not method).
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)