News for hackers. Stuff that matters.
Re:Let's Make a Varint by groovy2shoes on Monday May 09, 2016 @12:32AM (#11657637)
Any good reason not to just use a single sign bit?
Re:Let's Make a Varint by kentonv on Monday May 09, 2016 @01:26AM (#11657802)
Honestly, no, there's no "good" reason.

In practice the reason it ended up designed this way is because varint was introduced first with no special support for negative numbers, and then zigzag was introduced years later. Zigzag worked well because it stacked on top of the existing varint parser without changing it.

But for a new format with no backwards-compatibility constraints, it would probably make much more sense to use sign extension (so, the first encoded bit becomes the sign bit).

(I am the person who rewrote and open sourced protobufs at Google, though I am not the inventor.)

Re:Let's Make a Varint by groovy2shoes on Monday May 09, 2016 @02:09AM (#11657902)
Cool. Thanks :)