## 1.5. Technical Detail

The UPC has only numerals (digital number), without letters (such as ‘A’, ‘B’,… ) or other (control / function ) characters.

Total 12 decimal digits, its format/syntax is:

SLLLLLLMRRRRRRE

In which:

1. S – Start, E – End

fixed bit pattern 101

2. M – Middle

fixed bit pattern 01010, called guard bars

3. L – Left, R - Right

both have 6 digits, each digit is a 7 bits code

So, total bits = S + L + M + R +E = 3 + 7 * 6 + 5 + 7 * 6 + 3 = 95 bits

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.

For left digits and right digits:

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.

### 1.5.1. Bit Pattern of Digit

The bar-and-space patterns for each digit 0–9 are as follows:

Digit L Pattern R Pattern Widths
0 0001101 1110010 3211
1 0011001 1100110 2221
2 0010011 1101100 2122
3 0111101 1000010 1411
4 0100011 1011100 1132
5 0110001 1001110 1231
6 0101111 1010000 1114
7 0111011 1000100 1312
8 0110111 1001000 1213
9 0001011 1110100 3112

bit pattern for each numeral is designed to be as little like the others as possible, and to have no more than four consecutive 1s or 0s in order -> more easy to read and recognize it.

#### 1.5.1.1. Mirrored Bit Pattern Design

Numbers on the right side of the middle guard bars are optically the inverse of the numbers to the left. In other words, while a number on the left side of the UPC will be made up of black bars and white spaces, the same number on the right side would be indicated by the inverse (what was black on the left is now white and what was white is now black).

In the illustration above, the "4" digit (shown in detail) is 1011100 (bar × 1, space × 1, bar × 3, space × 2). If the "4" digit were on the left hand side it would be 0100011 (space × 1, bar × 1, space × 3, bar × 2).

This inversion enables the bar code to be scanned from left-to-right or right-to-left. Left-side digits consist of an even number of white space bits and an odd number of black bars. Right side digits are the opposite. Using this difference, the scanning software knows if it read the code the correct way or upside down.

### 1.5.2. 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 divided by 10.. 10 goes into 58 5 times with 8 leftover).
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

1. adding the odd-numbered digits (0 + 6 + 0 + 2 + 1 + 5 = 14), multiplying by three (14 × 3 = 42),
2. adding the even-numbered digits (42 + (3 + 0 + 0 + 9 + 4) = 58),
3. calculating modulo ten (58 mod 10 = 8),
4. subtracting from ten (10 - 8 = 2).

The check digit is thus 2.

This should not be confused with the real numeral "X" which stands for a value of 10 in modulo 11.

### 1.5.3. Prefixes

Prefix Value Usage/ Application Field
0[1], 1, 6, 7, 8 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 next 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. These coupons can be doubled or tripled
9 Coupons, The Manufacturer code is the LLLLL, the first 3 RRR are a family code (set by manufacturer), and the next 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. These coupons CANNOT be doubled or tripled
Note 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.