خوارزميات رقم التحقق: كيف يمنع الباركود الأخطاء

Embed This Widget

Theme


      
    

Widget powered by . Free, no account required.

A practical guide to Modulo 10, Modulo 43, and Modulo 103 check digit calculations with step-by-step worked examples.

Check Digit Algorithms: How Barcodes Prevent Errors

A check digit is a single character calculated from the data digits using a mathematical formula. It acts as a built-in error detector: if any digit is misread, the check digit calculation will fail, and the scanner rejects the read. Different barcode symbologies use different algorithms.

Modulo 10 (EAN/UPC)

The Modulo 10 algorithm protects EAN-13, EAN-8, UPC-A, and UPC-E barcodes. Here is the step-by-step process for EAN-13:

  1. Starting from the rightmost data digit (position 13), assign alternating weights of 1 and 3, moving left
  2. Multiply each digit by its weight
  3. Sum all the products
  4. The check digit is (10 - (sum mod 10)) mod 10

Example: For data 590123412345, the calculated check digit is 7, making the complete EAN-13 5901234123457.

This algorithm catches all single-digit errors and most transposition errors (two adjacent digits swapped), which account for over 90% of manual keying mistakes.

Modulo 43 (Code 39)

Code 39 uses Code 39 check digit algorithm dividing character sums by 43." data-category="Check Digit & Validation">Modulo 43 when a check character is required (it is optional in the base specification but mandatory in some industries):

  1. Assign each character a value (0-9 = 0-9, A-Z = 10-35, special characters = 36-42)
  2. Sum all character values
  3. Divide by 43 and take the remainder
  4. The character corresponding to that remainder is the check character

Modulo 103 (Code 128)

Code 128 always includes a Code 128 check digit using weighted positional values mod 103." data-category="Check Digit & Validation">Modulo 103 check character:

  1. Start with the symbology and scan direction." data-category="Barcode Anatomy & Structure">start character value (103, 104, or 105 depending on code set)
  2. Multiply each subsequent symbol character value by its position (1, 2, 3...)
  3. Add the start value plus all weighted values
  4. Divide by 103; the remainder is the check character value

Modulo 10 Weighted (ITF-14)

ITF-14 uses a variant of Modulo 10 where odd-position digits are weighted 3 and even-position digits are weighted 1 (the reverse of EAN-13's convention when counting from the left).

Error Detection Capabilities

Algorithm Single digit errors Adjacent transpositions Other errors
Mod 10 (EAN) 100% ~89% Variable
Mod 43 (Code 39) 100% ~98% Good
Mod 103 (Code 128) 100% 100% Excellent

When Check Digits Are Not Enough

Check digits catch substitution errors (wrong digit) but cannot recover data. For damage tolerance, 2D symbologies like Data Matrix use Reed-Solomon error correction, which can reconstruct missing data.