Bar Codes

The bar code. There on almost every product. Here’s a sample for what follows:

Officially, it’s called the Universal Product Code (UPC), writes Charles Petzold in Code:

“In its most common form, the UPC is a collection of 30 vertical black bars of various widths, divided by gaps of various widths, along with some digits.”

 

If it’s just a series of bits (1’s and 0’s), why is it so large then?

“To give the checkout person something to aim the scanner at.”

Each line is read as a 1. A thicker line conveys multiple 1’s, proportional to the thickness of the line. Each white gap is a 0, and a thicker gap conveys multiple o’s, again proportional to the thickness of the gap.

 

The left-most and right-most are always 101, and called the guard patterns:

“It allows the computer-scanning device to get oriented.”

Those guard patterns also tell the scanning device how thick a 1-line is, and how thick a 0-gap is:

“Otherwise, the UPC would have to be a specific size on all packages.”

 

The remaining lines are to be read in groups of 7. Each group conveys a single digit. Why so many lines for a single digit? Because it includes multiple error-checking bits (lines/gaps) within each digit. I won’t get into another detail as it is a bit more technical, but suffice to say that there is yet more redundancy built into each group of 7 that indicates whether the UPC is being scanned left to right or right to left. (That’s why the checkout person can hold the product upside down and things still work).

 

The two longer lines at the center of the bar code picture above? They too serve as error-checks. If the scanner doesn’t find those lines at the expected position, it knows something is wrong. Either in the scan attempt or via tampering or just poor printing.

 

Let’s say you did all of the above. What did you read? 0 36000 29145 2:

“This is very disappointing.”

It’s the number that’s printed on the UPC! Actually, those numbers are printed so that the checkout person can key them in if the bar code could not be read. But if the scanner works (as it does most of the time), it gets a lot of info (type of product, name of manufacturer, individual product details). One thing it doesn’t have? The price. Instead, the scanned bar code, which, as we just saw, include product details serves as input to the query asking the store database for the price. Why doesn’t the bar code include the price? You guessed it: because of those discounts stores want to give.

 

The humble bar code has now been demystified.

Comments

Popular posts from this blog

Student of the Year

Animal Senses #7: Touch and Remote Touch

The Retort of the "Luxury Person"