Commit 6520557d by Oliver Woodman

Add (not technically necessary 0xFF guard for clarity).

Without this, the byte is cast as follows (in bits) if the top
byte is set:

10000010 -> 1000000000000000000000000000010

This works because we then always shift at least one bit left,
and only look at the bottom 8 bits of the result. It's confusing
though. It's clearer if the cast to int gives just adds zeros to
the front, like:

10000010 -> 0000000000000000000000010000010
parent 06ddb036
......@@ -150,7 +150,7 @@ public final class BitArray {
public int readUnsignedByte() {
int value;
if (bitOffset != 0) {
value = (data[byteOffset] << bitOffset)
value = ((data[byteOffset] & 0xFF) << bitOffset)
| ((data[byteOffset + 1] & 0xFF) >>> (8 - bitOffset));
} else {
value = data[byteOffset];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment