Saramsha

No. 014  ·  30 September 2026

The Error Names Itself

Sixteen bits go down a wire and one of them arrives wrong. Nobody kept a copy, nobody can ask for a resend — and yet the block can say which bit broke. Four yes-or-no questions are enough. Click any bit to flip it.

message

About this piece

Four questions, sixteen answers

A single parity bit is the oldest trick in the book: count the 1s in a block, and append one more bit to make that count even. If a bit flips on the way, the count comes out odd and you know something is wrong. You do not know what, and you do not know where, so the only remedy is to ask for the whole block again. Down a telephone line you can ask. On a disc written ten years ago, in a radio signal that left Neptune four hours ago, in a stick of memory halfway through a calculation, there is nobody to ask. The block has to carry its own repair kit.

Richard Hamming worked at Bell Labs in the late 1940s and got the computer at weekends, when the mathematicians with more seniority had gone home. The machine was a Model V relay calculator, it checked parity on everything, and on finding a bad block it did the sensible thing: it gave up, dropped the job, and moved to the next one in the queue. So he would set a calculation running on Friday evening and come back on Monday to find it had died at ten past six. Twice in a row, by his account, and the second time he asked the question that produced the code in front of you: if the machine can tell that there is an error, why can it not tell where the error is? He worked it out over the following couple of years and published it in the Bell System Technical Journal in April 1950.

The idea is to use several parity bits, each watching a carefully chosen half of the block — and the choice is the whole trick. Number the sixteen positions 0 to 15 and write each number in binary, as the small grey digits in every cell do. Check 1 watches every position whose number has the 1s bit set: 1, 3, 5, 7, 9, 11, 13, 15. Check 2 watches every position with the 2s bit set: 2, 3, 6, 7, 10, 11, 14, 15. Check 4 takes 4–7 and 12–15; check 8 takes 8–15. Four checks, each over eight of the sixteen positions, and every position in its own distinct combination of them.

Now suppose bit 10 flips. Ten in binary is 1010, so bit 10 sits inside check 8 and check 2 and inside neither of the other two. So exactly those two checks come out odd — and no others can, because no other position belongs to precisely that pair. Write the four results down in order, 8 4 2 1, a 1 for each check that failed: 1010. Ten. The failing checks have not merely announced that something is wrong; they have spelled out the address of the casualty in binary. That is the whole of Hamming's code, and it is why the arrangement looks like a magic trick and is really just counting.

Two small pieces of housekeeping make it work cleanly. First, the check bits themselves live at positions 1, 2, 4 and 8, because those are the positions that belong to exactly one check each — position 4 is in check 4 and in nothing else. So each check bit can be set to fix up its own check without disturbing any of the others, which is why you can watch them settle independently as you edit the message. Second, if every check passes, the address they spell is 0000, and no check bit lives at position 0 — so that pattern is free to mean "nothing is wrong".

Count the answers and you can see why four checks is exactly the right number rather than a lucky guess. Four yes-or-no questions have sixteen possible answers. Fifteen of them name a position; the sixteenth means clean. Nothing is wasted, and nothing is missing. A code with that property is called perfect, and it is a real geometric statement: around each of the 211 valid 15-bit codewords sits a sphere of sixteen strings — itself, plus the fifteen you get by flipping one bit — and those spheres tile all 215 possible strings exactly, with no gaps and no overlaps. Every possible received block is within one flip of exactly one codeword. There is nowhere for a single error to hide.

Which is also the weakness, and the reason for the sixteenth bit. Positions 1, 2, 4 and 8 are four checks over fifteen bits: that is Hamming(15,11), and it corrects one error. Two errors defeat it — their two addresses combine and it points, with total confidence, at an innocent third bit. So one more plain parity bit is added over the entire block, here in the spare slot at position 0. Then the diagnosis has two stages. Checks fail and the whole block comes out odd: an odd number of errors, almost certainly one, so correct it. Checks fail and the whole block still comes out even: an even number of errors, so at least two — refuse to correct, flag the block, ask for a resend. And 0000 now has two readings told apart by that bit: everything is fine, or the sixteenth bit itself is the only casualty. Try each of those in the grid; Hit two gets you the double.

This pairing has a name, SECDED — single error correct, double error detect — and if you are reading this on a machine with error-correcting memory, it is happening several billion times a day underneath you, as a wider version of the same code: 64 bits of data with 8 check bits, on every read. That is Hamming(72,64), 89% of the wire carrying message. The insurance gets cheaper as the block gets bigger, because the number of checks grows like the logarithm of the block size — offset by the plain fact that a bigger block is likelier to be hit twice.

Hamming's code is the ancestor rather than the last word. Real damage is rarely one tidy bit: a scratch on a disc, a fading radio signal and a scuffed QR code all destroy runs of adjacent bits, and for those you need codes built to lose whole chunks. The Golay code brought the Voyager pictures back from Jupiter and Saturn; Reed–Solomon, published in 1960, is in every compact disc, every QR code you have ever scanned, and most of what has left the solar system since. All of them strike Hamming's bargain: spend some of the channel so that the message can point at its own wounds. He received the Turing Award for it in 1968.

All of this runs in your browser; nothing is uploaded. The message is eleven bits, so 2,048 of them exist and the New message button picks one at random. ?data=01101001101 in the address bar sets the eleven data bits directly and ?flip=10 — or ?flip=10,3 — chooses which bits arrive broken, so a particular state can be reproduced. Tab into the grid, then ← → ↑ ↓ to move and Space to flip; N hits one bit, 2 hits two, C applies the correction, U undoes the damage.