We Just Learned How Barcodes Work, And Our Minds Are Blown

What does nearly every single packaged food item have in common? If it's intended to be sold at a grocery store, you'll find a bar code — also called a UPC, or Universal Product Code — somewhere on it, and this has been the case since the mid-1970s. It makes checkout a breeze, with that familiar "beep" meaning that's it's been scanned and added to your purchased items, but how is a series of lines and numbers able to indicate what the name and price of an item is?

Each series of bars and spaces represents either a different number (or a "guard pattern" intended to separate the beginning, middle, and end of the code), and when a UPC code is scanned, those 12 numbers are run through the supermarket's central database, and the product's name and price is retrieved and added to the tally of items you're buying. That's actually the easy part. The way that those numbers become associated with individual food products is a lot more complicated.

When a food company produces a new item that they want to sell at grocery stores, they have to register with a company called the Uniform Code Council, who will assign them a six-digit manufacturer identification number; these are the first six digits of the bar code. A brand's manufacturer identification number doesn't change from product to product; for example, every General Mills product has a manufacturer identification number of 016000 (the really big manufacturers' numbers tend to have a lot of zeros in them).

The second set of five numbers, called the item number, is unique to the product. In fact, many big manufacturers have UPC coordinators on staff, just to make sure that all products are assigned unique item numbers and that the numbers of discontinued products are retired. The manufacturer only assigns the product's name to its number; the price is set at the point of sale.

If you look closely at a UPC code, you'll notice that the first and last numbers are set apart from the rest of the bunch. This is because those have special purposes as well. The first number is called the number system character, and this defines exactly what type of bar code it is; for example, a "3" indicates a pharmaceutical, a "5" indicates a coupon, and a "2" indicates a "random-weight item" like fruit or meat.

The last number is the most complicated one of all, but if you've already come this far then you might as well stick around for the thrilling conclusion. That stray digit at the end there is called the "error detecting check digit" and it lets the scanner self-check after each scan to make sure that it scanned the code correctly. As described by How Stuff Works, using the bar code 63938200039 (using only the code's first 11 digits), here's the calculation it makes:

"1. Add together the value of all of the digits in odd positions (digits 1, 3, 5, 7, 9 and 11). 6 + 9 + 8 + 0 + 0 + 9 = 3
2. Multiply that number by 3. 32 x 3 = 96
3. Add together the value of all of the digits in even positions (digits 2, 4, 6, 8 and 10). 3 + 3 + 2 + 0 + 3 = 11
4. Add this sum to the value in step 2. 96 + 11 = 107
5. Take the number in Step 4. To create the check digit, determine the number that, when added to the number in step 4, is a multiple of 10. 107 + 3 = 110
6. The check digit is therefore 3."

Again, the scanner does this calculation, nearly instantaneously, every time it scans an item. Computers: They're smarter than we are!

So, there you have it. That little series of bars and numbers is pretty cool, and we can thank IBM engineer George Laurer and his team for developing it back in the late '60s and early '70s.

Laurer is actually still alive, going strong at 92 years old. Click here to read about 10 other people who've enjoyed long careers influencing how we buy and eat food.