Worked example: 400638133393
Multiply the twelve data digits by these weights from left to right: 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3. The products are 4, 0, 0, 18, 3, 24, 1, 9, 3, 9, 9, 9. Their sum is 89.
The next multiple of ten is 90, so the check digit is 1. The complete sample is 4006381333931. A sum already divisible by ten produces check digit 0, not 10.
The formula
Compute (10 − (weighted sum modulo 10)) modulo 10. Applying modulo a second time handles the zero case. Use exactly twelve data digits for EAN-13; do not include the check digit in this calculation.
Our calculator displays each digit, its weight and its product. Keep a leading zero as a character; converting the identifier to a number can silently change its length.
UPC-A and EAN-8
UPC-A starts with eleven data digits; EAN-8 starts with seven. Use the same right-to-left alternating weights beginning with 3. The different body lengths change which leftmost weight you see.
To validate a complete identifier, remove its final digit, calculate the expected digit and compare them. Checking only the length misses many errors.
What this check cannot prove
The check digit is an error-detection rule, not a registry lookup. It does not certify product ownership, assignment or print quality.
After correcting the source data, generate the artwork and test the final label with the equipment that will receive it.