Skip to content
Items & stock

Barcode check digits explained, and why a mistyped barcode is refused

The last digit of every EAN-13, UPC-A and EAN-8 barcode is worked out from the others. Here is how that check digit is calculated, with worked examples, what it catches, and why MartPOS refuses a wrong barcode instead of guessing.

Arshad Ali Updated 5 min read

The number under the bars on a packet of biscuits is not just a number. Its last digit is a check digit, calculated from all the others, so that a mistyped digit shows up at once. That is why MartPOS can tell you a barcode is wrong the moment it is typed or imported, and why it refuses one rather than saving it. This guide shows the arithmetic, with worked examples, so you can check a barcode by hand if you ever need to. You can also try it in the barcode checker on the home page.

The three kinds a shop sees

  • EAN-13: 13 digits. The barcode on most packed goods sold in Pakistan.
  • UPC-A: 12 digits. Common on goods made for the American market.
  • EAN-8: 8 digits. Used on small packs where a full barcode does not fit.

All three use the same rule, set by GS1, the organisation that issues these numbers.

The rule

Take every digit except the last one. Starting from the rightmost of those digits and moving left, multiply them by 3, 1, 3, 1, and so on. Add up the results. The check digit is whatever must be added to that sum to reach the next multiple of 10. If the sum is already a multiple of 10, the check digit is 0.

A worked example: EAN-13

Take the sample number 896 1234 56789 4, chosen for this example. The first twelve digits are 8 9 6 1 2 3 4 5 6 7 8 9. Counting from the right, the 9 gets weight 3, the 8 weight 1, the 7 weight 3, and so on, which from the left reads 1, 3, 1, 3:

Digit896123456789
Weight131313131313
Product8276329415621827

The products add up to 136. The next multiple of 10 is 140, so the check digit is 140 − 136 = 4, and the full barcode is 8961234567894. Change any one digit, for example the last 4 to a 5, and the check no longer works: MartPOS would refuse 8961234567895.

A worked example: UPC-A

The well-known sample 0 12345 67890 5 has eleven digits before the check digit: 0 1 2 3 4 5 6 7 8 9 0. From the right, the weights are again 3, 1, 3, 1, which from the left reads 3, 1, 3, 1 … 3:

(0 × 3) + (1 × 1) + (2 × 3) + (3 × 1) + (4 × 3) + (5 × 1) + (6 × 3) + (7 × 1) + (8 × 3) + (9 × 1) + (0 × 3) = 85

The next multiple of 10 is 90, so the check digit is 5: 012345678905.

A worked example: EAN-8

For the sample 1234567 and its check digit: from the right, 7 × 3 + 6 × 1 + 5 × 3 + 4 × 1 + 3 × 3 + 2 × 1 + 1 × 3 = 60. That is already a multiple of 10, so the check digit is 0: 12345670.

What the check digit catches

  • Any single mistyped digit. Change one digit and the sum changes by an amount the check digit cannot hide.
  • Most swapped neighbours. Two neighbouring digits typed the wrong way round are caught, unless the two digits differ by exactly 5 (a 2 and a 7, for example).

It does not tell you which digit is wrong. That is why MartPOS never offers a "corrected" barcode: several different numbers could fix the sum, and only the packet in your hand knows the right one.

What MartPOS does with a barcode

  • When an item is saved or imported, a code of 13, 12 or 8 digits is checked as an EAN-13, UPC-A or EAN-8. If the check digit is wrong, MartPOS refuses it and asks you to scan it again or to read the digits under the bars once more.
  • Any other code, such as a supplier's own code or an old shop label, is kept exactly as it is. It scans to the item like any barcode.
  • An item can have several barcodes: the packet, the carton and your old labels. Each finds the right item and unit.
  • If two items carry the same code, the till asks which one you mean rather than picking one for you.
  • An item without any barcode keeps its own item code, and a Code 128 label of that code can be printed so it scans at the till.
  • MartPOS never makes up an EAN or UPC number. Those numbers are issued through GS1, and inventing one could clash with a real product.

Numbers starting with 2

EAN-13 numbers starting with 2 are set aside for use inside a shop or a region, so the same number can mean different goods in two different shops. MartPOS checks their check digit like any other. For goods you pack yourself, a code of your own with letters in it, such as SUG1KG, is simpler: it is kept exactly as typed, scans to the item like any barcode, and can never be mistaken for a maker's number. See barcodes for loose items.

Common questions

Why does MartPOS refuse a barcode instead of saving it with a warning?

Because a wrong barcode on an item never scans. The packet in the customer's hand would not be found at the till, and someone would have to type the name every time. Catching it when the item is saved is cheaper than at the counter.

Can MartPOS correct a wrong barcode for me?

No. The check digit shows that something is wrong, not what. Scan the packet again or read the digits under the bars.

What about codes with letters, or with 10 digits?

They are not EAN or UPC barcodes, so there is no check digit to verify. MartPOS keeps them as your own codes, and they scan to the item.

Do the first digits say where a product was made?

No. The first two or three digits are a GS1 prefix: they show which GS1 office issued the number, not the country of manufacture.

For how MartPOS keeps stock behind all these barcodes, see retail inventory software.

#barcode #EAN-13 #UPC-A #EAN-8 #check digit #retail inventory
AA
Arshad Ali

Founder & CEO, Innobrains Technologies

Arshad Ali is the founder and CEO of Innobrains Technologies, the company that is building MartPOS: point-of-sale, stock and khata software for kiryana stores, general stores and mini marts in Pakistan.

Run your shop on MartPOS

Barcode billing, loose goods and packs, khata and advances, on the shop's own PC without internet. We set it up on your shop PC with you.

Related guides

Items & stock

Selling atta, rice, daal and sugar by weight or by rupees

Half a kilo of daal, a pao of haldi, Rs 100 of sugar, a whole bag of atta. How a cashier bills loose goods by weight or by the rupee in MartPOS, why Rs 50 of sugar can come to Rs 50.08, and what the till checks on every line.

30 Sep 2026 · 6 min
Items & stock

Barcodes for loose items and the goods you pack yourself

Loose daal, rice and spices come without a maker's barcode, and so do the 1 kg packets you fill yourself. Two ways to make them scan at the till in MartPOS, which to use when, and why you should never make up an EAN-13 number.

30 Sep 2026 · 5 min