mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-01-20 09:17:29 +07:00
Moved BitConstraints#isUnsigned to BitUtils
This commit is contained in:
parent
90564f39a3
commit
871cadaa2b
@ -56,11 +56,6 @@ class BitConstraints {
|
|||||||
return validateSize(Long.SIZE, bits);
|
return validateSize(Long.SIZE, bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUnsigned(long value, int size) {
|
|
||||||
assert 0 < size && size <= Long.SIZE;
|
|
||||||
return (value & (1 << (size - 1))) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int validateAscii(int bits) {
|
public static int validateAscii(int bits) {
|
||||||
return _validateSize(Byte.SIZE - 1, Byte.SIZE, bits);
|
return _validateSize(Byte.SIZE - 1, Byte.SIZE, bits);
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ public class BitInput {
|
|||||||
public byte read7u(int bits) {
|
public byte read7u(int bits) {
|
||||||
BitConstraints.validate7u(bits);
|
BitConstraints.validate7u(bits);
|
||||||
final byte value = (byte) readUnsigned(bits);
|
final byte value = (byte) readUnsigned(bits);
|
||||||
assert BitConstraints.isUnsigned(value, Byte.SIZE);
|
assert BitUtils.isUnsigned(value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,7 +315,7 @@ public class BitInput {
|
|||||||
public short read15u(int bits) {
|
public short read15u(int bits) {
|
||||||
BitConstraints.validate15u(bits);
|
BitConstraints.validate15u(bits);
|
||||||
final short value = (short) readUnsigned(bits);
|
final short value = (short) readUnsigned(bits);
|
||||||
assert BitConstraints.isUnsigned(value, Short.SIZE);
|
assert BitUtils.isUnsigned(value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ public class BitInput {
|
|||||||
public int read31u(int bits) {
|
public int read31u(int bits) {
|
||||||
BitConstraints.validate31u(bits);
|
BitConstraints.validate31u(bits);
|
||||||
final int value = (int) readUnsigned(bits);
|
final int value = (int) readUnsigned(bits);
|
||||||
assert BitConstraints.isUnsigned(value, Integer.SIZE);
|
assert BitUtils.isUnsigned(value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ public class BitInput {
|
|||||||
public long read63u(int bits) {
|
public long read63u(int bits) {
|
||||||
BitConstraints.validate63u(bits);
|
BitConstraints.validate63u(bits);
|
||||||
final long value = (long) readUnsigned(bits);
|
final long value = (long) readUnsigned(bits);
|
||||||
assert BitConstraints.isUnsigned(value, Long.SIZE);
|
assert BitUtils.isUnsigned(value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user