Universal Product Code
The Universal Product Code (UPC) is a barcode symbology (i.e., a specific type of barcode), that is widely used in the United States and Canada for tracking trade items in stores.
Current code
In the UPC-A barcode, each digit is represented by a seven-bit sequence, encoded by a series of alternating bars and spaces. Guard bars, shown in green, separate the two groups of six digits.
The UPC encodes 12 decimal digits as SLLLLLLMRRRRRRE, where S (start) and E (end) are the bit pattern 101, M (middle) is the bit pattern 01010 (called guard bars), and each L (left) and R (right) are digits, each one represented by a seven-bit code. This is a total of 95 bits. The bit pattern for each numeral is designed to be as little like the others as possible, and to have no more than four 1s or 0s in order. Both are for reliability in scanning.
Since S, M, and E all include two bars, and each of the 12 digits of the UPC-A barcode consists of two bars and two spaces, all UPC-A barcodes consist of exactly (3*2)+(12*2)=30 bars.
The UPC has only numerals, with no letters or other characters. The first digit L is the prefix. The last digit R is an error correcting check digit, allowing some errors in scanning or manual entry to be detected. UPC data structures are a component of GTINs (Global Trade Item Numbers). All of these data structures follow the global GS1 standards.
The bar-and-space patterns for each digit 0–9 are as follows:
Digit |
Pattern |
Digit |
Pattern |
0 |
0001101 |
5 |
0110001 |
1 |
0011001 |
6 |
0101111 |
2 |
0010011 |
7 |
0111011 |
3 |
0111101 |
8 |
0110111 |
4 |
0100011 |
9 |
0001011 |
Before the Middle guard bars, a 1 indicates a bar, while a 0 indicates a space. After the Middle guard bars, however, the patterns are optically inverted. In other words, a 1 now indicates a space, and a 0 now indicates a bar. In the illustration above, the "4" digit (shown in detail), falls after the Middle guard bars, causing the pattern of bars and spaces to be inverted.
Prefixes
· 0, 1, 6, 7, 8, or 9: For most products.
· 2: Reserved for local use (store/warehouse), for items sold by variable weight. Variable-weight items, such as meats and fresh fruits and vegetables, are assigned a UPC by the store, if they are packaged there. In this case, the LLLLL is the item number, and the RRRRR is either the weight or the price, with the first R determining which.
· 3: Drugs by National Drug Code number. Pharmaceuticals in the U.S. have the remainder of the UPC as their National Drug Code (NDC) number; though usually only over-the-counter drugs are scanned at point-of-sale, NDC-based UPCs are used on prescription drug packages as well for inventory purposes.
· 4: Reserved for local use (store/warehouse), often for loyalty cards or store coupons.
· 5: Coupons The Manufacturer code is the LLLLL, the first 3 RRR are a family code (set by manufacturer), and the last 2 RR are a coupon code. This 2-digit code determines the amount of the discount, according to a table set by the GS1 US, with the final R being the check digit.
By prefixing these with a 0, they become EAN-13 rather than UPC-A. This does not change the check digit. All point-of-sale systems can now understand both equally.
Check digit calculation
In the UPC-A system, the check digit is calculated as follows:
1. Add the digits in the odd-numbered positions (first, third, fifth, etc.) together and multiply by three.
2. Add the digits in the even-numbered positions (second, fourth, sixth, etc.) to the result.
3. Find the result modulo 10 (i.e. the remainder when the result is divided by 10).
4. If the result is not zero, subtract the result from ten.
For example, a UPC-A barcode (in this case, a UPC for a box of tissues) "03600029145X" where X is the check digit, X can be calculated by adding the odd-numbered digits (0+6+0+2+1+5 = 14), multiplying by three (14 × 3 = 42), adding the even-numbered digits (42+3+0+0+9+4 = 58), calculating modulo 10 (58 mod 10 = 8), subtracting from ten (10 - 8 = 2). The check digit is thus 2.
Zero Compressed UPC-E
To allow the use of UPC barcodes on smaller packages where a full 12-digit barcode may not fit, a 'zero-compressed' version of UPC was developed called UPC-E. This symbology differs from UPC-A in that it only uses a 6-digit code, does not use middle guard bars, and the end bit pattern (E) becomes 010101. The way in which a 6-digit UPC-E relates to a 12-digit UPC-A is determined by the last (right-hand most) digit. With the manufacturer code represented by X's, and product code by N's then:
Last digit |
UPC-E equivalent is |
UPC-A equivalent is |
0 |
XXNNN0 |
0XX000-00NNN + check |
1 |
XXNNN1 |
0XX100-00NNN + check |
2 |
XXNNN2 |
0XX200-00NNN + check |
3 |
XXXNN3 |
0XXX00-000NN + check |
4 |
XXXXN4 |
0XXXX0-0000N + check |
5 |
XXXXX5 |
0XXXXX-00005 + check |
6 |
XXXXX6 |
0XXXXX-00006 + check |
7 |
XXXXX7 |
0XXXXX-00007 + check |
8 |
XXXXX8 |
0XXXXX-00008 + check |
9 |
XXXXX9 |
0XXXXX-00009 + check |
For example a UPC-E barcode with the number 654321 would expand to the UPC-A 065100004327.
UPC-E check digits are calculated using this expanded string in the same way as used by UPC-A. The resulting check digit is not added to the barcode, however, but is encoded by manipulating the parity of the six digits which are present in the UPC-E - as shown in the following tables:
Check digit |
Parity pattern |
0 |
EEEOOO |
1 |
EEOEOO |
2 |
EEOOEO |
3 |
EEOOOE |
4 |
EOEEOO |
5 |
EOOEEO |
6 |
EOOOEE |
7 |
EOEOEO |
8 |
EOEOOE |
9 |
EOOEOE |
Digit to be encoded |
Odd parity pattern |
Even parity pattern |
0 |
3-2-1-1 |
1-1-2-3 |
1 |
2-2-2-1 |
1-2-2-2 |
2 |
2-1-2-2 |
2-2-1-2 |
3 |
1-4-1-1 |
1-1-4-1 |
4 |
1-1-3-2 |
2-3-1-1 |
5 |
1-2-3-1 |
1-3-2-1 |
6 |
1-1-1-4 |
4-1-1-1 |
7 |
1-3-1-2 |
2-1-3-1 |
8 |
1-2-1-3 |
3-1-2-1 |
9 |
3-1-1-2 |
2-1-1-3 |