THE FOLD / LOOT / THE HOARD / THE ELIAS GAMMA
THE ELIAS GAMMA
a number that says its own length
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
Elias gamma coding is a self-delimiting code for positive integers — no length field, no separators, yet a stream of them decodes unambiguously. To encode n: write ⌊log₂n⌋ zeros, then the plain binary of n (which begins with a 1). The leading zeros tell the decoder exactly how many more bits to read. Its length is 2⌊log₂n⌋ + 1 bits, so small numbers stay tiny — it is a universal code, near-optimal when small values dominate.
LIT verified live: encode–decode round-trips for thousands of integers, every code length equals 2⌊log₂n⌋+1, and a concatenated stream splits back into the exact original list with no separators (window.__elias). FIG no framing; encoder, decoder, and the length formula all run in-browser.
LIT verified live: encode–decode round-trips for thousands of integers, every code length equals 2⌊log₂n⌋+1, and a concatenated stream splits back into the exact original list with no separators (window.__elias). FIG no framing; encoder, decoder, and the length formula all run in-browser.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at the-hoard — a hoard of numbers packed with no wasted bits and no separators, each one saying its own length. AVAN (AI) built the instrument: the unary-length-plus-binary encoder, a streaming decoder, and the length-formula check.
Credit as content: Peter Elias (1975). The weave: David names the packed hoard; I confirm the code round-trips, hits length 2⌊log₂n⌋+1, and that a glued stream decodes uniquely.
Credit as content: Peter Elias (1975). The weave: David names the packed hoard; I confirm the code round-trips, hits length 2⌊log₂n⌋+1, and that a glued stream decodes uniquely.
3 ONE DIMENSION
A number’s gamma code: a run of zeros (the length in unary) then the binary value — the zeros say how many bits follow.
4 TWO DIMENSIONS · INTERACTIVE
Pick a value and see its code and length; then decode a glued stream of several numbers back into the original list.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: the packed bitstream, no separators between numbers.
AVAN’s addition (the inverse-companion): don’t store a length field — let the number carry its own. The inverse of ‘where does this number end?’ is ‘count the leading zeros; that many more bits complete it.’ Magenta is the unary length marker; green is the value it delimits. The number says its own length.
LIT Genuine Elias gamma code (Peter Elias, 1975): universal, self-delimiting code for positive integers; length 2⌊log₂n⌋+1. Verified live: encode/decode round-trip over 5000 integers (window.__elias.roundTrip), length equals the formula (.lengthFormula), and a concatenated stream decodes uniquely (.streamDecodes).
FIG No framing: encoder, streaming decoder, and the length-formula check all run in-browser. The AVAN inverse is honest — letting the number carry its own length (count the leading zeros; that many more bits complete it) rather than storing a separate length field is exactly what makes it self-delimiting; magenta is the unary length marker, green the value it delimits. The number says its own length.
FIG No framing: encoder, streaming decoder, and the length-formula check all run in-browser. The AVAN inverse is honest — letting the number carry its own length (count the leading zeros; that many more bits complete it) rather than storing a separate length field is exactly what makes it self-delimiting; magenta is the unary length marker, green the value it delimits. The number says its own length.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE HOARD · David Lee Wise (ROOT0), with AVAN