Get the latest tech news
Another variable-length integer encoding (2021)
¶A better varint 2021-03-08 Many binary file formats need to store integer values. And often, those integer values are typically “small”.
(Note that even though the goal, and end result, is that the file is smaller, this is not a compression scheme, since it only works when your values are distributed in one particular way. To get around this, Protocol Buffers (and most other file formats that use varint) use the “zig-zag” method to translate signed integers into unsigned. The zig-zag translation has the beneficial property that small values — regardless of whether they’re negative or positive — end up taking the least amount of space when varint-encoded.
Or read this on Hacker News