---
title: A corrupted bit: how to fix it without knowing which one it is
url: https://jarroba.com/en/when-a-bit-gets-corrupted/
author: Ramón Invarato
date: 2026-11-11
modified: 2026-11-11
language: en
license: CC BY-NC-SA 3.0 (https://creativecommons.org/licenses/by-nc-sa/3.0/) — attribution: "A corrupted bit: how to fix it without knowing which one it is", Ramón Invarato, jarroba.com
categories: Artificial intelligence
tags: ai, AI course, Artificial Intelligence, ECC, Error correction, Hamming code, Parity Bit, SECDED
series: Level 0 — How a machine sees the world (part 3 of 4)
---

# A corrupted bit: how to fix it without knowing which one it is

> How a computer finds and fixes a corrupted bit without knowing which one it is: the Hamming code, its limits and SECDED. AI course, 0.3.

Everything a computer stores is numbers in binary, and sometimes one of those bits changes by itself: a 0 turns into a 1 inside a memory chip or along the way. By adding three bits for every four, a computer can find the wrong bit and fix it without anyone telling it which one it is, as long as only one bit is wrong.

 

## Try this first

 

Open **[the Hamming Code tool with the data `1011`](https://jarroba.com/tools/en/hamming?data=1011)**. The tool adds three bits and returns **0110011**: seven bits where there used to be four. The ones in positions 1, 2 and 4 are the added ones (parity bits); the other four are your data.

 

[![The data 1011 in the Hamming Code tool: the encoded word 0110011, with the parity bits p1, p2 and p4 in orange](https://jarroba.com/wp-content/uploads/2026/11/palabra-codificada-www.jarroba.com_-1024x335.png)](https://jarroba.com/wp-content/uploads/2026/11/palabra-codificada-www.jarroba.com_.png)

 

Now open **[the same word with the fifth bit wrong](https://jarroba.com/tools/en/hamming?data=1011&errors=5)**, as if it had changed along the way (in the tool it is the one labeled `p5`, under **Simulate an error**; you can also change it yourself by clicking on it). The tool answers **“Corrected — error at position 5”**, and nobody told it which one it was.

 

[![With the fifth bit changed, the tool answers "Corrected — error at position 5", syndrome 5 = 101 in binary](https://jarroba.com/wp-content/uploads/2026/11/error-en-p5-www.jarroba.com_-1024x194.png)](https://jarroba.com/tools/en/hamming?data=1011&errors=5)

 

Next: **[the word with the fifth and second bits wrong](https://jarroba.com/tools/en/hamming?data=1011&errors=5,2)**. Two bits changed. The answer is **“Corrected — error at position 7”**, and 7 was fine. The decoder has just changed a correct bit and treats the result as good: the four data bits that come out are no longer `1011` but `1110`. (The warning box that appears below is added by the tool to explain it; a real decoder would not show it.)

 

[![With bits 5 and 2 changed, the tool answers "Corrected — error at position 7" and changes a bit that was fine](https://jarroba.com/wp-content/uploads/2026/11/dos-errores-www.jarroba.com_-1024x266.png)](https://jarroba.com/wp-content/uploads/2026/11/dos-errores-www.jarroba.com_.png)

 

Finally, **[the same two errors with SECDED turned on](https://jarroba.com/tools/en/hamming?data=1011&errors=5,2&secded=1)** (SECDED is a variant explained below). Now the answer is **“Double error detected”**.

 

[![The same two errors with SECDED: the word has an eighth bit, P0, and the answer is "Double error detected"](https://jarroba.com/wp-content/uploads/2026/11/secded-error-doble-www.jarroba.com_-1024x194.png)](https://jarroba.com/wp-content/uploads/2026/11/secded-error-doble-www.jarroba.com_.png)

 

## What just happened

 

In a computer’s memory, a bit can change by itself because of electrical noise or alpha particles, as [Synopsys, which designs memory controllers](https://www.synopsys.com/articles/ecc-memory-error-correction.html) explains; and a message traveling over a cable or through the air can also arrive with a bit changed.

 

The simplest way to find out is the **parity bit**: you add a bit that makes the total number of ones always even. If it arrives odd, something has changed. But it only says that there is an error, not where it is.

 

What Richard Hamming did was use several parity bits, each one watching a different group of positions, and make those groups overlap. You have it in the **Coverage of each parity bit** table of the tool:

 
- P1 watches positions 1, 3, 5 and 7.
- P2 watches positions 2, 3, 6 and 7.
- P4 watches positions 4, 5, 6 and 7.

 

[![The coverage table: which positions each parity bit, P1, P2 and P4, watches](https://jarroba.com/wp-content/uploads/2026/11/cobertura-www.jarroba.com_.png)](https://jarroba.com/wp-content/uploads/2026/11/cobertura-www.jarroba.com_.png)

 

When bit 5 changes, the two that watch it, P1 and P4, complain, but P2 does not. Add up the ones that complain: 1 + 4 = 5. That sum is the position of the error. The tool writes it as **“syndrome 5 = 101₂”**: in binary, each digit says whether a check has failed (P4 yes, P2 no, P1 yes). It is called a syndrome, as in medicine: the set of symptoms points to where the problem is. If you want to follow this process step by step, with all the rules and much more detail, it is explained in [Hamming Code: Error Detection and Correction](https://jarroba.com/en/hamming-code-error-detection-correction/).

 

However, with two errors, the self-correcting trick backfires. Bit 5 makes P1 and P4 complain; bit 2, P2. All three complain, 1 + 2 + 4 = 7, and the code, which is built on the assumption that there is only one error, points at position 7 and treats the word as corrected, even though it is still wrong.

 

**SECDED** (*Single Error Correction, Double Error Detection*) adds one more bit, **P0**, which goes in front of all the others and watches the parity of the whole word. That is why with SECDED the word has eight bits instead of seven. With one error, the two clues agree and it is corrected. With two, the groups say that something is wrong but the total parity adds up; that is only possible if an even number of bits has changed, so instead of “correcting” it warns of a double error.

 

The idea was born out of an annoyance. In the late 1940s, Hamming used a relay computer at Bell Labs that, when it detected an error and there were no operators around (at night and on weekends), abandoned the job and moved on to the next one. Weekends were exactly when Hamming worked, and every error forced him to start his programs from scratch. In a taped interview, he said: “Damn it, if the machine can detect an error, why can’t it locate the position of the error and correct it?” ([*Hamming code*, on Wikipedia](https://en.wikipedia.org/wiki/Hamming_code), which cites the interview). He published the answer in 1950, in the [*Bell System Technical Journal*](https://doi.org/10.1002/j.1538-7305.1950.tb00463.x).

 

And it is still in use: the DDR4 memory modules with **ECC** (*error-correcting code*) in servers use a SECDED scheme with 8 check bits for every 64 data bits ([Synopsys](https://www.synopsys.com/articles/ecc-memory-error-correction.html)).

 

## The classic mistake

 

You might think parity bits are wasted space: in the example, 3 out of every 7 bits carry no data. But that cost drops quickly as the block grows (you can check it in “Try it yourself”, below), and what it buys is the ability to fix an error without asking for the message again.

 

The second confusion is more dangerous: reading “Corrected” as “correct”. The code guarantees what it promises only if what it assumes holds (at most one error per word). Beyond that, it does not stop or warn: it returns a wrong answer with the same confidence as a good one. It is a behavior worth recognizing early, because any system that always gives an answer behaves the same way, AI models included.

 

## Try it yourself

 

In the **Encode** tab of the **[Hamming Code](https://jarroba.com/tools/en/hamming)** tool, type any 11 data bits and see how many parity bits the tool adds and what **rate** (the part of the word that is data) comes out. Before doing it with 26 bits, make a guess: how many parity bits will it need? Check it.

 

Then open **[the Simulator](https://jarroba.com/tools/en/hamming?tab=sim)**: send some data 2000 times over a channel where each bit has a 2% chance of getting corrupted. Click **Simulate** with SECDED off and again with **[SECDED on](https://jarroba.com/tools/en/hamming?tab=sim&secded=1)**. Look at the **Silent failure** line. Then raise the probability to 10%. Why does the silent failure grow much faster than the failure probability of each bit? Think about what has to happen for there to be one.

 

The simulator’s numbers are random, so they change a little on each run; what matters is how they move when you change the settings.

 

## Further reading

 

- On Jarroba there are two articles from 2016 that go into the detail, with the rules step by step: [Hamming Code: Error Detection and Correction](https://jarroba.com/en/hamming-code-error-detection-correction/) and, more technical (Hamming distance, spheres, the syndrome matrix), [Hamming Distance, Weight, Space and Spheres Explained](https://jarroba.com/en/hamming-distance-weight-space-spheres/). And one about the simplest version of the idea: [Check Digit – Error Detection](https://jarroba.com/en/check-digit-error-detection/).
- Hamming’s original paper (1950): [Error detecting and error correcting codes](https://doi.org/10.1002/j.1538-7305.1950.tb00463.x).

## Series: Level 0 — How a machine sees the world

1. [Everything is a number (yes, even your name)](https://jarroba.com/en/everything-is-a-number.md)
2. [An image is a table of numbers](https://jarroba.com/en/an-image-is-a-table-of-numbers.md)
3. [A corrupted bit: how to fix it without knowing which one it is](https://jarroba.com/en/when-a-bit-gets-corrupted.md)
4. [What is a model (and why a straight line already counts as one)](https://jarroba.com/en/what-is-a-model.md)

