How to Calculate the EAN-13 Check Digit (With a Worked Example)
Why barcodes have a check digit
A barcode scanner must be sure it read every digit correctly. The final digit is calculated from the first twelve, so if one digit is misread the numbers no longer match and the scanner can reject the read instead of returning a wrong product.
The calculation
- Write the first 12 digits.
- Multiply the digits in odd positions (1st, 3rd, 5th and so on) by 1 and the digits in even positions (2nd, 4th, 6th and so on) by 3.
- Add all the results together.
- The check digit is the number that must be added to the sum to reach the next multiple of 10. If the sum already ends in 0, the check digit is 0.
Worked example
Take the first 12 digits 400638133393.
- Odd positions times 1: 4 + 0 + 3 + 1 + 3 + 9 = 20
- Even positions times 3: (0 + 6 + 8 + 3 + 3 + 3) x 3 = 23 x 3 = 69
- Sum: 20 + 69 = 89
- Next multiple of 10 is 90, so the check digit is 1.
The full barcode number is 4006381333931.
How to validate a full code
Apply the same weights to all 13 digits, with the 13th digit having weight 1. If the total is a multiple of 10 the number is valid. LuckyScanner uses this check to flag barcode numbers that were misread.
A valid check digit only proves the number is well formed. It does not prove the product exists in a database.