Commit 06ddb036 by ojw28

Merge pull request #260 from mine260309/dev-hls

Fix a signed right shift issue in BitArray.readUnsignedByte()
parents b30f55f1 80602b16
...@@ -148,16 +148,15 @@ public final class BitArray { ...@@ -148,16 +148,15 @@ public final class BitArray {
* @return The value of the parsed byte. * @return The value of the parsed byte.
*/ */
public int readUnsignedByte() { public int readUnsignedByte() {
byte b; int value;
if (bitOffset != 0) { if (bitOffset != 0) {
b = (byte) ((data[byteOffset] << bitOffset) value = (data[byteOffset] << bitOffset)
| (data[byteOffset + 1] >> (8 - bitOffset))); | ((data[byteOffset + 1] & 0xFF) >>> (8 - bitOffset));
} else { } else {
b = data[byteOffset]; value = data[byteOffset];
} }
byteOffset++; byteOffset++;
// Converting a signed byte into unsigned. return value & 0xFF;
return b & 0xFF;
} }
/** /**
......
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