Variable-length quantity in Midi files
Recently, while looking at the binary data of MIDI files, I found about Variable Length Quantity, a clever method for storing very large quantities using just a few hexadecimal numbers.
Using a single byte (1 ascii character = 1 hexadecimal number)
we could represent quantities from 0 to 127 (In hexadecimal 00 to 7F)
With two bytes, from 0 to 16383 (hexadecimal 0000 to FF7F)
Three bytes, from 0 to 2,097,151 (hexadecimal from 000000 to FFFF7F)
Four bytes, from 0 to 268,435,455 (hexadecimal from 00000000 to FFFFFF7F)
This stack is a simple interface for code posted by Paul McCleman in Rosetta Code:
https://rosettacode.org/wiki/Variable-length_quantity#LiveCode