How Do Error-Correcting Codes Work?
A 10-minute read
Error-correcting codes add computed extra bits to a message so a receiver can find and fix corrupted data itself, with no resend needed.
Error correction works by sending extra bits computed from the data rather than copied from it, so a receiver holding a corrupted message can work out which positions were damaged and repair them without asking the sender to repeat anything. That is why a scratched CD still plays and why a command sent to a probe 25 billion kilometers away still arrives intact. The scale of the trick is also easy to miss. The same mathematics hardens the server memory in a data center, keeps a QR code readable through a coffee stain, and corrects errors in a 5G radio link. On that deep space link a request for a resend would take two full days to complete a round trip, so the repair has to happen locally.
The short answer
Error-correcting codes add redundant bits to a message using a mathematical rule the receiver already knows, so a corrupted copy carries enough information to identify the damage and repair it in place. The cost is bandwidth; the benefit is that no retransmission is required, which is the only workable option on a link where the round trip takes longer than the data is worth.
The full picture
A weekend of frustration with a relay computer
Richard Hamming worked at Bell Labs on the Model V, an electromechanical relay machine whose cycle times were measured in seconds. Input came in on punched paper tape, seven-eighths of an inch wide, with up to six holes per row. During the week, when the relays misbehaved, the machine stopped and flashed lights so operators could fix it. On nights and weekends, when nobody was around, it simply moved on to the next job and silently produced wrong answers.
Hamming worked on weekends and grew tired of restarting his programs from scratch. In a taped interview he said: “And so I said, ‘Damn it, if the machine can detect an error, why can’t it locate the position of the error and correct it?’” He spent the following years building the algorithms, and in 1950 published what became known as the Hamming code.
The code he focused on, the Hamming (7,4), takes four data bits and adds three parity bits to make a seven-bit codeword. Three parity bits are enough to pin down the position of any single flipped bit, because the pattern of which parity checks fail spells out a binary number that is the address of the bad bit. The code detects a one-bit or two-bit error and repairs any single-bit error, which is exactly the design goal of the Hamming code. It is also a perfect code, meaning no code with that block length and that repair ability can carry more information per bit.
From bit flips to block damage
Parity bits detect errors but cannot repair them. Going further requires working on groups of data rather than single bits, and it requires arithmetic that survives noise.
Irving Reed and Gustave Solomon hit this in 1960. Both were staff at MIT Lincoln Laboratory, working on the SAGE air defense system, where radar data moved between sites over noisy links. Their idea was to treat the message as a set of numbers, evaluate a polynomial through them, and ship the polynomial’s values alongside the original data. When the decoder replays the same arithmetic, a mismatch does not merely flag a problem, it locates the error and reverses it.
The result was a family of codes, RS(n, k), where the n-k check symbols let the decoder detect any combination of up to n-k bad symbols, and locate and correct up to half of that many when the positions are unknown. The arithmetic runs over a finite field rather than ordinary numbers, so the operations are exact and never drift. The codes were not practical for long. The MIT Lincoln Laboratory account of the work notes that the machines of the day could not decode them efficiently. In 1977 NASA’s Voyager program adopted Reed-Solomon for deep-space communication, achieving a data rate of 21,600 bits per second from 2 billion miles away while consuming less energy than a wristwatch battery. The Hubble Space Telescope, launched in 1990, still relies on them. Today the codes sit inside optical discs, television broadcasts, and RAID storage arrays.
Two families, two jobs
Block codes like Reed-Solomon and Hamming take a fixed chunk of data, add redundancy, and solve for the whole chunk at once. Convolutional codes work differently. They treat the stream as a shift register, where each output bit depends on the last few input bits, which spreads the effect of a single error across several following symbols. The decoder then searches the possible paths and picks the most likely one, usually with the Viterbi algorithm.
Spacecraft lean on this combination. NASA’s own guide to deep space telecommunications explains that most interplanetary missions use forward error correction based on convolutional coding with Viterbi decoding, and that Cassini flew a rate of one bit per six symbols, so a downlink of 82,950 bits per second required a symbol rate of 497,700 per second. Reed-Solomon is layered on first to handle burst damage, the kind where a run of consecutive bits is destroyed at once.
That layering is the point. A detailed study of the space codes describes the standard CCSDS arrangement: Reed-Solomon as the outer code and a convolutional code as the inner one. Each handles the kind of damage the other is bad at.
What it costs, and what it buys
Redundancy is not free. Every check bit carries no new information, so a code trades capacity for reliability. Too much redundancy and the channel spends its time carrying checksums. Too little and errors leak through.
Claude Shannon put a ceiling on the whole enterprise in 1948. His channel coding theorem says that for any channel with a given noise level, there is a maximum rate at which information can be sent with arbitrarily small probability of error. Below that rate, reliable communication is possible. Above it, it is not, no matter how clever the code. The overview of forward error correction notes that Shannon’s proof was not constructive, which left a long gap between knowing the limit existed and being able to reach it.
The codes that closed that gap arrived in stages. Robert Gallager proposed low-density parity-check codes in his 1960 MIT doctoral dissertation, then saw them largely ignored because iterative decoding was too slow for the hardware of the day. They were rediscovered in the mid-1990s, when the hardware had caught up and patents on the competing turbo codes made the free alternative attractive. The history of low-density parity-check codes describes them as producing order-of-magnitude gains over the codes that came before.
The most recent arrival is the polar code, developed by Erdal Arikan at Bilkent University. It is the first code with an explicit construction that provably reaches channel capacity, and its encoding and decoding cost only O(n log n) operations. A comprehensive review of the codes behind 5G explains how both families are actually built and decoded today.
That matters because 5G is where modern error correction reaches the public. 3GPP adopted polar codes for the control channels that tell a phone how to join the network, and low-density parity-check codes for the data channels that carry the payload, after Huawei demonstrated a 27 Gbit/s field trial using polar codes in October 2016. The Wikipedia account of polar codes notes the tradeoff that kept them off the data channel: at the block lengths industry actually uses, their performance trails the well-established alternatives.
Every scratched disc and every shipping label
The clearest demonstration of the whole idea is a scratched CD. The audio data is stored in blocks, each protected by Reed-Solomon check symbols, and the player interleaves those blocks so a scratch spreads the damage thinly across many of them rather than destroying one outright. The decoder reconstructs the missing samples from the parity, and the audible result is a click instead of a gap.
QR codes use the same mathematics with a different trade. The standard defines four correction levels, L, M, Q and H, which recover roughly 7, 15, 25 and 30 percent of the codewords respectively. A Level H code can in theory lose 30 percent of its codewords and still scan, but only if the damage avoids the three large finder patterns in the corners, which a scanner must read before any correction can begin. That is why a code printed with a logo punched through the middle still reads, while one torn across a corner does not.
The same principle turns up in computer memory, where extra bits called ECC protect server RAM against cosmic rays, and in flash storage, where low-density parity-check codes let a controller rebuild a worn-out cell. The link between redundancy and compression is easy to confuse: compression strips redundancy on purpose to save space, while error correction adds it back in a controlled form to survive damage.
The link that cannot be repaired
The strongest argument for error correction comes from the case where correcting is the only option. Voyager 1 crossed into interstellar space in August 2012 and, as of October 2026, sits at about 172 astronomical units, some 25.8 billion kilometers away. A radio command takes close to 24 hours to reach it, and a reply takes almost as long. A corrupted frame cannot be fixed by asking again, because the retransmission would arrive two days later and the science would already be gone.
So the redundancy has to be paid for up front, in the transmission itself, on the assumption that the channel is bad and that some of the added bits will arrive wrong too. That is why the same family of techniques shows up in deep space links, in the cellular networks in your pocket, and in the satellites overhead.
Why it matters
Redundancy is a budget with a hard constraint. In the Hamming (7,4) code, only four of every seven bits on the wire carry information, a code rate of about 57 percent. Reed-Solomon codes are quoted the same way: RS(255,223) spends 32 bytes of every 255 on parity. A link that must be essentially error free cannot avoid that tax, but the size of the tax tells you how hard the environment is fighting you. A copper cable inside a data center and a radio beam across the solar system do not pay the same price.
Error correction also changes what a device can promise. A CD player is not just a laser and a motor; it is a decoder that can rebuild a sample the disc no longer holds, which is the difference between a click and a skipped track. A server’s ECC memory can report a corrected error to the operating system instead of silently returning wrong data, which is the difference between a warning and a corrupted database. When you see ECC memory on a server specification, or hear that a solid-state drive uses low-density parity-check codes, you are reading the price of that promise.
The third consequence is about limits. Shannon’s ceiling means there is a hard line between reliable and impossible for any given channel, and every code in use is a way of getting as close to that line as the hardware allows. That is why the field waited more than three decades for hardware to catch up with Gallager’s codes, and why a polar code that provably reaches capacity still had to fight its way into a standard. Error correction is the part of digital communication where mathematics and manufacturing have to arrive on the same schedule.
Common misconceptions
“Error correction just means sending the data more than once.” Repetition does correct errors, and it is a legitimate code, but it is an extraordinarily expensive one. Sending each bit three times repairs a single error in every group of three and burns two thirds of the channel on redundancy. Reed-Solomon achieves useful protection with a fraction of that overhead because its redundancy encodes relationships between groups of bits rather than copies of the bits themselves.
“A checksum or a hash does the same job.” Detection and correction are different requirements. A checksum or a cryptographic hash tells you that something changed, and often not where or how much. Correction needs structured redundancy from which the decoder can solve for the damaged positions. The relation between the two is direct: an erasure, a position known to be damaged, costs one check symbol to repair, while a corruption whose location is unknown costs two.
“If the link uses error correction, no errors ever get through.” Every code has a designed limit and stops working past it. A Reed-Solomon code with n-k check symbols can locate and correct up to half of them, and beyond that it can flag the block as unrecoverable but cannot fix it.
Key terms
Forward error correction (FEC): Redundancy added to data before transmission so the receiver can repair errors without a retransmission. The only option when a round trip is slow or impossible.
Parity bit: A single extra bit recording whether a group of data bits contains an odd or even number of ones. It detects an odd number of errors but cannot repair them.
Hamming code: A family of error-correcting codes invented by Richard Hamming in 1950. The (7,4) version carries four data bits plus three parity bits and repairs any single-bit error.
Reed-Solomon code: A block code introduced by Irving Reed and Gustave Solomon in 1960. It works on groups of symbols, and with n-k check symbols it can locate and correct up to half of them.
Code rate: The fraction of transmitted bits that carry new information. The Hamming (7,4) code runs at about 57 percent, and every check bit costs bandwidth.
Interleaving: Spreading consecutive blocks of data across a medium so a burst of damage is thinned out across many blocks, leaving each one repairable.
Shannon limit: The maximum rate at which information can be sent over a noisy channel with arbitrarily small probability of error. Reliable transmission above it is impossible.
Common questions
What is an error-correcting code?
An error-correcting code adds structured redundancy to data before it is sent or stored, so a receiver can identify and repair corrupted bits without asking for the data again. The redundancy is not a copy of the data. It is a set of mathematical relationships between the data bits, chosen so that a small number of corruptions produce a distinctive pattern that points straight at the damaged positions.
How is error correction different from error detection?
Error detection only tells you that something went wrong, which is all a simple parity bit does. Error correction goes further and works out which bits changed, so it can repair them. Detection plus a reverse channel can also recover data, but only when a fast round trip is possible, and that is exactly what is missing on a link to a spacecraft tens of billions of kilometers away.
Why not just send the data twice?
Repeating data does correct errors, but it is a very expensive way to do it. Sending each bit three times can repair a single error in every group of three, and it spends two thirds of the channel on redundancy. Reed-Solomon codes buy comparable protection with a fraction of the overhead, because their redundancy encodes relationships between groups of bits rather than copies of the bits themselves.
Do error-correcting codes make a connection slower?
They cost bandwidth, since every redundant bit is a bit carrying no new information. What they buy is a much higher effective throughput, because a link that needs no retransmission keeps sending useful data instead of resending. The right code for a link adds just enough redundancy to keep the error rate low without wasting the channel.
Where is error correction used every day?
Almost everywhere digital data moves. It sits in ECC server memory, in flash drives and SSDs, in CD and DVD players, in QR codes, in the radio links of 5G networks, in deep space links, and in the modems and satellite links that carry television.
That's the distilled version.