Apex › Data & encoding

How a barcode works (UPC check digit)

The bars are just 12 digits a laser can read, and the last one isn’t data — it’s a mod-10 check digit computed from the other eleven that exists only to catch errors. Real UPC-A encoding (L/R codes + guard bars, 95 modules) and the real formula (odd positions ×3 + even, completed to a multiple of 10). Click a digit and every single-digit error goes red — all caught. Then slip one past it: transpose two neighbours with the ⇄ handles, and swapping two that differ by 5 (the 2 and the 7) spells a different, still-valid product — the scanner accepts the wrong item. No checksum catches everything. The same idea as an ISBN, a credit card’s Luhn digit, and every packet checksum.

More in Data & encoding