Universal Product Code

related topics
{math, number, function}
{system, computer, user}
{@card@, make, design}
{company, market, business}
{style, bgcolor, rowspan}
{area, community, home}
{build, building, house}
{area, part, region}
{disease, patient, cell}
{game, team, player}
{mi², represent, 1st}

The Universal Product Code (UPC) is a barcode symbology (i.e., a specific type of barcode), that is widely used in Canada and the United States for tracking trade items in stores.


Current code

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 consecutive 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:

A binary 1 is always indicated by a black bar while a 0 is indicated by a white space. 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 x 1, space x 1, bar x 3, space x 2). If the "4" digit were on the left hand side it would be 0100011 (space x 1, bar x 1, space x 3, bar x 2). This inversion enables the barcode to be scanned from left-to-right or right-to-left. Since the same number is represented differently based on where it lies in the code, the scanning software knows if it read the code the correct way or upside down.

Full article ▸

related documents
Code refactoring
Range encoding
Reverse Polish notation
Turing completeness
Basic Encoding Rules
Syntactic sugar
GNU Octave
Bridge pattern
Linear congruential generator
Interchange File Format
Greedy algorithm
Heaviside step function
Logarithmic integral function
Magma (algebra)
Separated sets
Polynomial time
Twin prime conjecture
Intersection (set theory)
Topological ring
Goldbach's weak conjecture
Kernel (category theory)
Euler's criterion