Added some bit operation functions

This commit is contained in:
Ziver Koc 2024-09-07 00:00:52 +02:00
parent 3cd3a2fc7c
commit e4d9a16ebd
3 changed files with 118 additions and 47 deletions

View file

@ -157,4 +157,11 @@ public class ByteUtilTest {
assertArrayEquals( new byte[]{0b0000_0000,0b0000_0001,0b0000_0001,0b0000_0001},
ByteUtil.shiftLeft(new byte[]{0b0001_0000,0b0001_0000,0b0001_0000,0b0001_0000}, 4));
}
@Test
public void invert() {
assertEquals((byte) 0b1111_1110, ByteUtil.invert((byte) 0b0000_0001));
assertEquals((byte) 0b0000_1111, ByteUtil.invert((byte) 0b1111_0000));
assertEquals((byte) 0b0000_1000, ByteUtil.invert((byte) 0b1111_0111));
}
}