-
Notifications
You must be signed in to change notification settings - Fork 1
toggleAs
Subhajit Sahu edited this page Jul 25, 2022
·
18 revisions
Toggle bits as per mask.
toggleAs(x, m)
// x: an int32
// m: bit mask
const xbit = require('extra-bit');
xbit.toggleAs(6, 1);
// → 7 (110,000 ⇒ 111)
xbit.toggleAs(6, 7);
// → 1 (110,111 ⇒ 001)
xbit.toggleAs(6, 3);
// → 5 (110,011 ⇒ 101)