-
Notifications
You must be signed in to change notification settings - Fork 1
set
Subhajit Sahu edited this page Jul 25, 2022
·
15 revisions
Set bits at specified index.
set(x, i, [f])
// x: an int32
// i: bit index
// f: bit value (1)
const xbit = require('extra-bit');
xbit.set(6, 0, 1);
// → 7 (110,0,1 ⇒ 111)
xbit.set(6, 2, 1);
// → 6 (110,2,1 ⇒ 110)
xbit.set(6, 2, 0);
// → 2 (110,2,0 ⇒ 010)