Skip to content

toggleAs

Subhajit Sahu edited this page Jan 17, 2021 · 7 revisions

Toggles bits as per mask. 📰 📘

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

Bit.toggleAs(x, m);
// x: an int or long
// m: bit mask
import io.github.javaf.*;

Bit.toggleAs(6, 1);
// 7 (110,000 => 111)

Bit.toggleAs(6, 7);
// 1 (110,111 => 001)

Bit.toggleAs(6, 3);
// 5 (110,011 => 101)


References

Clone this wiki locally