mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-01 10:24:30 +07:00
Created readRaw(int) and added support for correctly reading signed 64 bits
This commit is contained in:
parent
d1ee547530
commit
af480bdfc3
@ -115,6 +115,10 @@ public class BitStream {
|
||||
return readBoolean() ? 1 : 0;
|
||||
}
|
||||
|
||||
public long readRaw(int bits) {
|
||||
return readUnsigned(bits);
|
||||
}
|
||||
|
||||
public long readUnsigned(int bits) {
|
||||
Validate.inclusiveBetween(0, Long.SIZE, bits, "bits must be in range [0,64]");
|
||||
if (bits == 0) return 0;
|
||||
@ -161,6 +165,10 @@ public class BitStream {
|
||||
}
|
||||
|
||||
public long readSigned(int bits) {
|
||||
if (bits == Long.SIZE) {
|
||||
return readRaw(bits);
|
||||
}
|
||||
|
||||
final int shift = Long.SIZE - bits;
|
||||
return readUnsigned(bits) << shift >> shift;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user