Details
-
Type:
Bug
-
Status: Resolved
-
Priority:
Trivial
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 4.1
-
Component/s: .compression
-
Labels:None
Description
The original code (in comment) does not work properly. Next line after each comment fixes this (at least in my experiments):
public int readMinimalBinary(final int b) throws IOException {
final int log2b = BitUtilities.mostSignificantBit(b);
final int m = (1 << log2b + 1) - b;
final int x = readBinary(log2b);
if (x < m) {
// return x + 1;
return x;
} else {
// int temp = (x << 1) + readBinary(1);
int temp = (x << 1) + readBinary(1) - m;
return temp;
}
}
public int readMinimalBinary(final int b) throws IOException {
final int log2b = BitUtilities.mostSignificantBit(b);
final int m = (1 << log2b + 1) - b;
final int x = readBinary(log2b);
if (x < m) {
// return x + 1;
return x;
} else {
// int temp = (x << 1) + readBinary(1);
int temp = (x << 1) + readBinary(1) - m;
return temp;
}
}
Great. Do you have a test case patch for the TestCompressedBitFiles ?
Craig