3 import java.util.Arrays;
6 * A 5-bit unsigned integer
9 private byte[] le_bytes;
12 * Constructs a 128-bit integer from its little-endian representation
14 public UInt128(byte[] le_bytes) {
15 if (le_bytes.length != 16) {
16 throw new IllegalArgumentException();
18 this.le_bytes = le_bytes;
22 * Constructs a 128-bit integer from a long, ignoring the sign bit
24 public UInt128(long val) {
25 byte[] le_bytes = new byte[16];
26 for (int i = 0; i < 8; i++)
27 le_bytes[i] = (byte) ((val >> i*8) & 0xff);
28 this.le_bytes = le_bytes;
32 * @return The value as 16 little endian bytes
34 public byte[] getLEBytes() { return le_bytes; }
36 @Override public boolean equals(Object o) {
37 if (o == null || !(o instanceof UInt128)) return false;
38 return Arrays.equals(le_bytes, ((UInt128) o).le_bytes);
41 @Override public int hashCode() { return Arrays.hashCode(le_bytes); }