libkate
0.4.1
|
Small integers are often needed, and the Kate bitstream format has a way to store them using a fraction of a byte to save space. This format is simple on purpose, and is not optimal. However, it allows easy compression of bitstreams using lots of small integers. All 32 bit integers may be represented by this encoding.
A variable length integer is stored in the following way:
A few examples:
Simple alterations would allow even more compression for typical numbers (eg, offsetting the numbers to allow -1 (a common occurence) to be stored on 4 bits, and noticing that the first bit of the bitstream stored last for large numbers is always 1), but are left for a possible future bitstream change as this would mean either an incompatible change, or a use for very few values, making the change almost pointless.