PR #9798 - changes from review
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
dca4e9832e
commit
c855f4ca55
|
@ -43,7 +43,7 @@ public class NBitIntegerEncoder
|
||||||
int lz = Long.numberOfLeadingZeros(value);
|
int lz = Long.numberOfLeadingZeros(value);
|
||||||
int log = 64 - lz;
|
int log = 64 - lz;
|
||||||
|
|
||||||
// The return value is 1 for the prefix + the number of 7-bit groups used to encode the value.
|
// The return value is 1 for the prefix + the number of 7-bit groups necessary to encode the value.
|
||||||
return 1 + (log + 6) / 7;
|
return 1 + (log + 6) / 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,8 @@ public class NBitIntegerEncoder
|
||||||
long length = value - bits;
|
long length = value - bits;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if ((length & ~0x7F) == 0)
|
// The value of ~0x7F is different to 0x80 because of all the 1s from the MSB.
|
||||||
|
if ((length & ~0x7FL) == 0)
|
||||||
{
|
{
|
||||||
buffer.put((byte)length);
|
buffer.put((byte)length);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue