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

Set a bit. 📰 📘

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


Bit.set(x, i, [f]);
// x: an int or long
// i: bit index
// f: bit value (1)
import io.github.javaf.*;

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

Bit.set(6, 2, 1);
// 6 (110,2,1 ⇒ 110)

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


References

Clone this wiki locally