Barcodes: The Universal Product Code

4. The Universal Product Code

The universal product code (UPC) is another familiar barcode that incorporates a system of error detection. The standard code used on items sold in American supermarkets (with the exception of items that are small and typically cylindrical, for which a special variant code was developed) consists of 11 information digits and a check digit. (The European version of this system is somewhat different.) Originally, the code was organized into four blocks, but because of the popularity of the code and the breadth of its use, the original standard has had to be modified so as to flexibly code the desired information. In any case the check digit works as follows: add the digits in the odd positions of the string which forms the code sequence, and multiply by 3; now take the digits in the even positions, sum them, and add to the previous answer. Finally, the check digit is chosen so that when it is added to the value, the result is a number which is divisible by 10 (ends in a zero).

Example:

Find the check digit (i.e. the value for the ? ) for the UPC number:

3 05212 90500 ?

The digits in the odd positions are 3, 5, 1, 9, 5, and 0. These sum to 23, which tripled yields 69. The digits in the even positions are 0, 2, 2, 0, and 0. These sum to 4, which, when added to 69, gives 73. Thus, the check digit is 7, because 73 + 7 = 80 is divisible by 10.

Symbolically, if we denote the code string, including the check digit by:

u1u2u3u4u5u6u7u8u9u10u11u12

We compute the check digit u12 so that:

R = 3(u1 + u3 + u5 + u7 + u9 + u11 )+ (u2 + u4 + u6 + u8 + u10 + u12)

is congruent to zero modulo 10. If one is dealing with a legal UPC code, then R 0 mod 10 holds for the code.

Welcome to the
Feature Column!

These web essays are designed for those who have already discovered the joys of mathematics as well as for those who may be uncomfortable with mathematics.