UPC Bar Code

The 12-digit universal product code (UPC) is in widespread use on items for sale in the United States and many other countries. This Demonstration is designed to illustrate how the UPC number is encoded into the familiar looking bars seen on packaging. When the "show details" option is selected, guide lines appear. These guide lines show that each digit in the UPC number is represented by a sequence of seven bars. The bar code begins and ends with a 3-bar "guard bars" pattern and the bar code is separated into two parts by the 5-digit "center bars". Moving the cursor over the UPC number will show what the various parts of the number represent, and moving the cursor over the individual digits/spaces above the bar code will show a large graphic of the coding of those symbols.



  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


The code for a digit depends on whether the digit appears before or after the center bars. The two codes for a digit are complements of each other (1's become 0's, 0's become ones; see snapshot 1). Several of the fixed examples are designed to allow easy comparison of the bars corresponding to certain digits before and after the space bars. See snapshots 2–4.
The last digit is the check digit. While the check digit does not always appear on the printed UPC code on a product, the bars for the check digit are always there. Given a UPC number , the check digit is chosen so that the weighted sum is divisible by 10.
[1] COMAP, For All Practical Purposes, New York: W. H. Freeman and Company, 2009.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2018 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+