What Is a Check Digit and How Does It Catch Errors?
That last number on a barcode isn't random — it's a check digit. How a simple formula catches scanning and typing mistakes.
A check digit is a barcode's built-in lie detector. It is a single extra digit, calculated from all the others, whose only purpose is to reveal when a code has been scanned or typed wrong. Understanding how it works shows you why a mistyped product number almost never sails through unnoticed. 🐾
What is a check digit?
A check digit is a redundancy digit: a number computed from the other digits in a code using a fixed formula, then tacked onto the end. When the code is later scanned, the reader runs the same formula on the incoming digits and checks whether the result still matches that final digit. If it does not, something was misread, and the scanner rejects the code rather than acting on bad data.
The digit carries no product information of its own. It is pure error detection. This idea sits inside a much bigger family of techniques, which we survey in error detection versus correction and checksums, hashes and parity. In a barcode it is the last, quiet line of defence against a slipped scan.
How does the UPC and EAN check digit work?
UPC-A and EAN-13 both use a mod-10 weighted algorithm. The clever part is the alternating weighting: the digits are not simply added up. Instead, alternate digits are multiplied by 3 and the rest by 1 before summing, which is why it is often called the 3-1 weighting.
Here is the recipe for a UPC-A, whose first 11 digits are the data and whose 12th digit is the check:
- Take the 11 data digits and number them from the left.
- Add up the digits in the odd positions (1st, 3rd, 5th, and so on) and multiply that sum by 3.
- Add up the digits in the even positions (2nd, 4th, 6th, and so on) and multiply that sum by 1.
- Add the two results together to get a total.
- Find what you must add to reach the next multiple of 10. That number, the mod-10 complement, is the check digit.
In short, the check digit is whatever makes the whole weighted sum divide evenly by 10.
A worked example, step by step
Let's calculate the check digit for the UPC-A whose 11 data digits are 03600029145. Numbering from the left, the digits sit in positions 1 through 11.
| Position | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Digit | 0 | 3 | 6 | 0 | 0 | 0 | 2 | 9 | 1 | 4 | 5 |
Step 1 — odd positions (1, 3, 5, 7, 9, 11): 0 + 6 + 0 + 2 + 1 + 5 = 14. Multiply by 3: 14 × 3 = 42.
Step 2 — even positions (2, 4, 6, 8, 10): 3 + 0 + 0 + 9 + 4 = 16.
Step 3 — total: 42 + 16 = 58.
Step 4 — mod-10 complement: 58 divided by 10 leaves a remainder of 8. To reach the next multiple of 10 (which is 60) we need to add 2. So the check digit is 2.
The complete, valid UPC-A is 036000291452. If a scanner ever reads a different final digit, the math will not add up, and the code is rejected.
One tidy detail: when the remainder is already 0, the check digit is 0, not 10. That is what "mod-10" guarantees, a single digit every time.
What errors does a check digit catch?
The mod-10 weighted scheme is deliberately designed to catch the two most common human and machine slip-ups.
Single-digit errors
If any one digit is misread, say a 3 becomes an 8, the weighted total shifts and no longer lands on a multiple of 10. A check digit catches every single-digit error.
Transposition errors
A transposition is when two adjacent digits get swapped, like typing 21 instead of 12, a classic finger fumble. Because neighbouring positions carry different weights (one is multiplied by 3, the other by 1), swapping them usually changes the total, so most transpositions are caught too.
What errors can slip through?
No single check digit is perfect, and it is honest to say so. The 3-1 weighting misses a specific, narrow case: a transposition of two adjacent digits that happen to differ by exactly 5. For example, swapping a 1 and a 6 leaves the weighted total unchanged, because the difference the swap creates is a multiple of 10 and vanishes under mod-10.
These blind spots are rare, which is why a single check digit is enough for retail. When far higher reliability is needed, systems layer on stronger schemes, from longer checksums to the full error correction built into 2D codes, described in QR code error correction. A check digit is a smart guard, not an unbreakable one.
Why does this matter for everyday barcodes?
Every time a cashier's scanner beeps, that beep means the check digit passed. A failed beep, or a "please scan again," often means the reader caught a misread before it could charge you for the wrong item. This tiny piece of math, quietly running billions of times a day, is a big reason barcodes are trusted.
The whole system of who issues these numbers and keeps them unique is coordinated globally, as we explain in GS1 barcode standards, and you can see where the retail code came from in the UPC barcode history. If you would rather encode a full message than a lookup number, you can create a free QR code whose grid carries its own, far more powerful error correction.
Frequently asked questions
What is a check digit?
It is an extra digit calculated from the other digits in a code using a fixed formula. A scanner recomputes it on the digits it reads and rejects the code if the result does not match, catching misreads.
How is the UPC check digit calculated?
Add the digits in odd positions and multiply by 3, add the digits in even positions, sum both results, then take the number needed to reach the next multiple of 10. That mod-10 complement is the check digit.
What does the 3-1 weighting mean?
Alternate digits are multiplied by 3 and the rest by 1 before summing. Giving neighbouring positions different weights is what lets the scheme catch most transposition errors.
What errors does a check digit miss?
The UPC and EAN scheme catches every single-digit error and most transpositions, but it can miss a swap of two adjacent digits that differ by exactly 5, because that change cancels out under mod-10.
Do QR codes use a check digit?
QR codes go further, using built-in error correction that can both detect and repair damage, rather than a single check digit that only detects errors.
Make a QR code the honest way 🐾
Free forever, no tracking, no expiry — generated right in your browser.