A photo from the Voyager probe travels 20 billion kilometers, through cosmic radiation that flips bits at random, and still arrives on your screen pixel-perfect. How?
It's not that the signal avoids errors. It can't. Deep space is loud, Wi-Fi drops packets, and even the copper wire in your wall picks up noise. The signal gets corrupted constantly. The trick is that the message is built so the receiver can catch the damage and undo it, without ever asking the sender to repeat anything.
That trick has a name: error-correcting codes. And the core idea behind it is simpler, and weirder, than you'd expect.
Every channel makes mistakes
Any time you send a bit, a single 0 or 1, through a real physical channel, there's some chance it flips. Electrical noise, a scratched CD, a weak Wi-Fi signal, a cosmic ray hitting a satellite chip. It all adds up to the same abstract problem: you send a bit, and with some probability , the receiver gets the wrong one.
Watch what happens as that probability climbs.
Every bit crosses a noisy zone. Turn up the noise and watch a growing fraction of 1s and 0s flip before they arrive.
At low noise, most bits sail through untouched. But notice something: even a small flip chance, applied to millions of bits, guarantees that some of them will be wrong. You can't prevent that. What you can do is design around it.
The obvious fix: just repeat yourself
The first idea anyone has is repetition. Send each bit three times. If the copies disagree, trust the majority.
The original bit is 1, sent as three copies. Click any copy to simulate it flipping in transit, then check the vote.
Try flipping just one copy: the vote still comes out right, because two out of three still agree. That's error correction. Not just noticing something's wrong, but recovering the original value.
But flip two copies and the vote flips with them. The majority is now wrong, and there's no way to tell. Worse, this scheme costs you 3x the bandwidth for every real bit of information you send. That's a steep price for protection that fails as soon as two things go wrong at once.
We need something that doesn't just repeat data, it needs to be smarter about how the redundancy is spent.
A smarter kind of redundancy
Here's a classic trick from medicine that turns out to be the same math. Say a lab has 7 patients and wants to know who, if anyone, is infected. Testing each person individually takes 7 tests. Instead, the lab pools samples into overlapping groups, say, group A contains patients , group B contains , group C contains , and runs just 3 tests, one per group.
Now suppose group A comes back positive, group B negative, group C positive. Only one patient sits in exactly "A and C, but not B": patient 5. The pattern of positive and negative results, not any single test, tells you exactly who's sick.
That's the whole idea behind smart error correction. Instead of asking "is something wrong?" over and over on separate copies, you design overlapping checks so the combination of pass/fail results spells out exactly where the problem is.
Turning the pattern into a location
Let's do the same thing with bits instead of patients. Take a 7-bit message and split it into three overlapping "check groups," exactly like the patient pools above. Each group is really a parity check: XOR together every bit in the group, and the result should be 0. If it's 1, something in that group flipped.
Click any of the 7 bits to flip it. Watch which checks go unbalanced, the pattern always points straight at the broken bit.
Click any single bit. Watch which checks flip to "odd." Every one of the 7 positions sits in a different combination of the three circles, so the specific pattern of failed checks always points at exactly one bit and only one. No searching, no guessing. Read off which circles are unhappy, and you've found your broken bit. Click it again to fix it and confirm the checks go back to all-even.
This is called a Hamming code, named after Richard Hamming, who invented it in 1950 while frustrated that his employer's computer would abort an entire job over a single bad bit.
The math: parity checks as equations
Now that the picture makes sense, the notation writes itself. Label the 7 positions through . Positions hold parity bits; positions hold your actual data. Each parity bit is defined so that a specific group of positions XORs to zero:
Here just means XOR: add without carrying, so . Which positions go in which group isn't arbitrary. Write each position's index in binary, and a parity bit checks every position whose binary code has a 1 in that bit's place. Position is 101, so it's covered by (bit 0) and (bit 2), but not (bit 1). That binary labeling is the whole trick.
When the receiver re-runs the three checks on a possibly-corrupted codeword, it gets three new bits, called the syndrome:
If , nothing's wrong. If it's anything else, read those three results as a binary number, most significant bit first, and that number is the position of the flipped bit. A single wrong bit at position 5 always produces syndrome 101, because position 5's own binary code is 101. The syndrome doesn't just detect the error. It's literally the error's address.
The fourth satellite, but for bits: how much redundancy do you need?
Three parity bits let you pinpoint one error among 7 total bits, using only 4 bits of real data. That's a 4/7 rate, better than repetition's 1/3, but still a lot of overhead.
Here's the encouraging part: this scales. With parity bits, you can cover a block of total bits, correcting any single error, while of those bits carry real data.
More parity bits means a longer block, but a shrinking fraction of it is overhead. Slide r and watch the rate climb.
Slide up and watch the rate climb toward 100%, even though the block is getting longer and the correction power stays fixed at "fix exactly one error." The relative cost of protection shrinks as the message grows, because a fixed number of parity bits gets spread across an exponentially larger block.
That's not the end of the story. Real systems, Wi-Fi, deep space links, QR codes, need to survive more than one flipped bit at a time, so they use more powerful relatives of this idea, like Reed-Solomon codes (the ones that let a scratched CD still play) or LDPC codes (used in modern Wi-Fi and 5G). But every one of them rests on the same foundation: structure your redundancy so the pattern of failures tells you exactly what broke.
The short version
Noisy channels flip bits, and you can't stop that. Simple repetition catches errors but wastes bandwidth and breaks down once two things go wrong together. The better approach groups bits into overlapping parity checks, like pooled medical tests, so the specific combination of failed checks points directly at the exact bit that's broken. Read that pattern as a binary number, called the syndrome, and it hands you the error's location for free. Add more parity bits and you can protect longer messages at a shrinking relative cost. That one idea, structured overlap instead of blind repetition, is what lets a signal cross 20 billion kilometers of empty space and still arrive exactly right.
All visualizations are interactive React components running entirely in your browser, computing real XOR parity checks and syndrome decoding live as you click. No libraries beyond React.