VarNumDecodes
object VarNumDecodes
Value members
Concrete methods
Decode variable-length integer which has maximum bits of maxBits.
Decode variable-length integer which has maximum bits of maxBits.
Quoting from https://wiki.vg/Protocol,
> These are very similar to Protocol Buffer Varints: > the 7 least significant bits are used to encode the value > and the most significant bit indicates whether there's another byte after it > for the next part of the number. > > The least significant group is written first, followed by each of the more significant groups; > thus, VarInts are effectively little endian (however, groups are 7 bits, not 8).
For example, consider the following byte stream obtained from network whose head is expected to be a variable-integer:
10001001 10010101 01111000 10100111 ...
Since third byte has the most significant bit set to zero, variable-integer data ends here.
X0001001 X0010101 X1111000 | 10100111 ...
Lower 7 bits from each byte is aggregated, and we obtain little-endian 7bit blocks:
0001001 0010101 1111000 0000000 0000XXX
In big endian 8bit blocks, this data corresponds to
00000000 00011110 00001010 10001001