That makes perfect sense. Thank you for your answer.
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 spec, but just something some people did
> manually to encode negative numbers efficiently. Eventually we made it
> official. Your encoding would work equally well, but cannot really be
> implemented independently of varint itself, therefore could not have evolved
> into existence in this way.
> On Fri, Jan 14, 2011 at 12:07 AM, David Srbecky <dsrbe...@gmail.com> wrote:
> > 126 is 0000 0000 0111 1110 in binary. We truncate it form the left to
> > groups of seven: 0000000 1111110 and then encode it as usual (least
> > significant group first): 1 1111110 0 0000000. It takes two bytes to
> > encode, but so does the zig-zag encoding.
> > In fact, the zig-zag encoding and the two's complement encoding always
> > take the same number of bytes to encode a given number.
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Protocol Buffers" group.
> > To post to this group, send email to firstname.lastname@example.org.
> > To unsubscribe from this group, send email to
> > protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
> > .
> > For more options, visit this group at
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to email@example.com.
To unsubscribe from this group, send email to
For more options, visit this group at