How Do Barcodes Work?

If you were born before 1970 or so, you undoubtedly remember that the responsibilities of the clerk at a grocery store were different than they are today. Back in the murky past, the clerk picked up each item that was being purchased, looked for a price tag, and manually entered that price into the cash register. This required time, accuracy, and endurance on the part of the cashier. One little slip of the fingers could change the price of a candy bar from 99 cents to $99.

You don’t have to be a zebra to benefit from black and white stripes.

This all changed on April 1, 1974. It wasn’t just the date that made spectators suspect they were witnessing an elaborate hoax. The event itself defied any logical explanation. A clerk at Marsh’s Supermarket in Troy, Ohio passed a package of Wrigley’s gum over a beam of red light. With no further action by the clerk, the price of the product magically appeared on the cash register. It was the first commercial use of the UPC barcode, and it revolutionized commerce.

No longer is it necessary for a cashier to look for prices, key data into the cash register, or even (if yesterday’s trip to the store is any indication) acknowledge the existence of the customer. All that is needed is a barcode and a way to read it.

The barcode that is found on the items you purchase is officially known as a Universal Product Code (UPC). GS1 is the company that creates the standards for their use. They may look like random patches from the skin graft of a zebra, but there are rules that govern how they appear.

Take, for example, this UPC code for the highly-addictive gateway drug, Peanut Butter M&Ms:

The code consists of alternating black and white lines of varying width. The black lines are called bars. The white lines are called spaces. They are divided by three identical sets of two bars separated by a space at the beginning, middle, and end:

Each of the bars and spaces can be one of four widths. The skinniest of these are the bars used to mark the start, middle, and end. The next largest is twice the width of the first. The next is three times that of the first, and the widest is — you guessed it — four times the width of the first. If we call the space occupied by the smallest a “module,” there is room for a total of 95 modules in a standard UPC barcode.

The beginning and ending markers consist of two bars and a space each for a total of six modules. The middle has an additional space on each side, so it takes up five modules. This leaves 84 modules to represent the 12 digits in a UPC code.

Each number consists of two bars and two spaces. Those numbers are represented thusly:

That is what they look like on the left side of the code, that is. They appear differently on the right side so the scanner can tell which side is “up.” The right side numbers look like this:

Now that you know what the numbers are, you should understand what they mean. The first three numbers make up the country prefix. This identifies the country of origin for the company that produces the product. It does not necessarily reflect the country in which the product is manufactured. Country codes are assigned by GS1. The list can be found here.

Next comes the company code. The size of the company code varies, and that is because of what comes after it. What remains after the company code is reserved to be used by the company to identify its product. For companies that produce a lot of different items, it stands to reason that they would want shorter company codes. The shorter the company code becomes, the fewer codes there are available. You could purchase a company code from GS1 for as little as $250, but that would leave you only one digit remaining to identify your product. If your company is only responsible for no more than ten products, that would be fine. If you have more, then you will need a shorter company code. You can purchase one as short as 6 digits for a whopping $10,500. That would give you enough remaining digits to identify 100,000 products, but there are only 1,000 6-digit codes available for each country.

Once a company assigns a code to one of its products, that code goes into a central global database so it can quickly be identified anywhere on earth.

The final digit in the UPC code is called the check digit. It is there to verify that the scanner has read the entire code correctly. Here is how it does that:

  • Add all the digits in the odd positions together (the 1st, 3rd, 5th, 7th, 9th, and 11th digits).
  • Multiply the result by 3.
  • Add to this the sum of the even-positioned digits (the 2nd, 4th, 6th, 8th, and 10th), not including the check digit itself.
  • “Chop off” everything except the final digit of your answer, the number in the ones place.
  • If that number is 0, that is the check digit.
  • If that number is any other digit, subtract it from 10, and the result is the check digit. For example, if the previous step resulted in an answer of 8, you would calculate 10-8=2. This answer should be the same as the final 12th digit of the barcode.

Now that you know all the tricks about UPC codes, you can amaze your friends by reading the code without the benefit of a laser scanner, even if the numerals do not appear at the bottom of the code.

Of course, if you have the time and inclination to memorize all these rules, our guess is that you don’t have a whole lot of friends to impress in the first place.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.