July 21, 2026
Byte me: ternary turns messy
How to pack ternary numbers in 8-bit bytes
Math nerds found a sneaky way to cram 5 tiny values into 1 byte — and the comments got spicy
TLDR: The post shows a clever way to squeeze five three-state values into one byte with almost perfect efficiency, which matters for making some AI models smaller and faster. Commenters were split between admiration for the math trick, confusion over the explanation, and delight in turning a tiny packing hack into full-blown nerd drama.
A deceptively niche math post about squeezing five ternary values — think numbers that can only be -1, 0, or 1 — into a single 8-bit byte somehow turned into a full-on comment section spectacle. The author’s trick is simple in spirit but wild in execution: pack these tiny values almost perfectly, then unpack them fast enough for use in modern AI models. For the efficiency crowd, this was basically catnip. One commenter gushed that it was “impressive how close to optimal this is,” then immediately escalated into even bigger, weirder block sizes like 111 values in 176 bits and 161 in 256, because of course someone had to turn a clever hack into a competitive sport.
But the real fun came from the confusion, nitpicking, and pure internet energy. One reader basically stared at the “fixed point numbers to the rescue” explanation and replied with the engineering equivalent of “bestie… what are you talking about?” That comment brought the classic Hacker News vibe: half admiration, half public cross-examination. Another person jumped straight to practical panic, asking whether this means AI matrices now need dimensions in multiples of 40, which is exactly the kind of oddly specific concern that makes these threads sing.
And because no tech thread is complete without one chaos goblin, someone dropped a Daily WTF link like a drive-by joke. The result? A glorious split between people calling the trick nearly perfect, people demanding a clearer explanation, and people just enjoying the sheer absurdity of watching byte-packing discourse become drama.
Key Points
- •The article proposes packing 5 ternary digits into 1 byte because `3^5 = 243` is close to `2^8 = 256`.
- •This 5-trit-per-byte layout uses 1.6 bits per trit, which the article states is 99.06% of the theoretical optimum.
- •Packing is done by interpreting five trits as a base-3 number, converting values from `-1,0,1` to `0,1,2`, and scaling the result into an 8-bit byte.
- •Unpacking avoids modulo and division by repeatedly multiplying the byte value by 3, extracting the next trit from the upper bits, and masking the remainder.
- •The article includes Python implementations and mentions a C verification program that checks the scheme is lossless for all 243 possible 5-trit combinations.