[protobuf] Re: Zig Zag Encoding (vs two's complement encoding)

2011-01-19 Thread David Srbecky
That makes perfect sense. Thank you for your answer. David On Jan 19, 4:37 am, Kenton Varda ken...@google.com wrote: The reason ZigZag encoding evolved as it did is because it can be applied as a separate layer on top of varint encoding.  Originally, ZigZag was not officially part of the

[protobuf] Re: Zig Zag Encoding

2011-01-14 Thread David Srbecky
126 is 0111 1110 in binary. We truncate it form the left to groups of seven: 000 110 and then encode it as usual (least significant group first): 1 110 0 000. It takes two bytes to encode, but so does the zig-zag encoding. In fact, the zig-zag encoding and the two's