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

Merge bits as per mask. 📰 📘

Similar: merge, interleave.


Bit.merge(x, y, m);
// x: first int or long
// y: second int or long
// m: bit mask (0 ⇒ from x)
import io.github.javaf.*;

Bit.merge(0x12, 0x24, 0x0F);
// 20 (0x14)

Bit.merge(0x1234, 0xABCD, 0x0F0F);
// 6973 (0x1B3D)

Bit.merge(0xAAAA, 0xBBBB, 0x3333);
// 48059 (0xBBBB)


References

Clone this wiki locally