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