bijou64: A variable-length integer encoding
26 points by justinweiss
26 points by justinweiss
So this a very neat canonical encoding of 64-bit integers. Is it possible to design a canonical-by-construction encoding for arbitrary integers (or more likely: does it already exist)?
Git has a canonical variant of the usual 7 bit encoding https://github.com/git/git/blob/master/varint.c which can be extended to signed numbers by putting the sign in the least significant bit (zigzag encoding).
I’ve implemented almost this encoding before — I thought of offsetting by 0xF8, but not of offsetting by larger amounts for longer values. Clever!