Skip to content
Subhajit Sahu edited this page Jan 24, 2021 · 7 revisions

Toggle a bit. 📰 📘

Alternatives: toggle, toggleAs.
Similar: get, set, toggle.


Bit.toggle(x, i);
// x: an int or long
// i: bit index
import io.github.javaf.*;

Bit.toggle(6, 0);
// 7 (110,0 ⇒ 111)

Bit.toggle(6, 1);
// 4 (110,1 ⇒ 100)

Bit.toggle(6, 2);
// 2 (110,2 ⇒ 010)


References

Clone this wiki locally