Hello,
Each byte in a varint, except the last byte, has the most significant bit
(msb) set – this indicates that there are further bytes to come. The
lower 7 bits of each byte are used to store the two's complement
representation of the number in groups of 7 bits, least significant group first.
I wonder if i can strictly depend on this definition and make from varint something like fixed-length-varints, for example i would like to encode "0" or "1" as varint using 4 bytes.
Example of "0" encoding:
LSbyte... MSbyte
0x80 0x80 0x80 0x00
Example of "1" encoding:
LSbyte... MSbyte
0x81 0x80 0x80 0x00
I know that it might be something that "breaks" the key-idea behind the varints, still i am doing this to keep my serializer simple and performant. My question is can i depend on such behavior or its something that might be changed in future by adding some "new magic" to this varint-wire-format ?
Best Regards,
Lukasz