Chapter 2. The Beauty of Codes

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

CHA PTER 2.

THE BEA UTY OF CODES

Subject: GEC104 (Mathematics in the Modern World)


Module 2
Lesson Title: The Beauty of Codes (6 Hrs)

Lesson Objectives: At the end of this chapter, the student is expected to


1. give the equivalent in Hindu-Arabic of the numerals from other number systems.
2. give the importance of barcodes
3. use check digits for error detection.

Overview/Introduction:
Codes were already around since the time of our ancestors. A code is a symbolic way to
represent information. In qualitative inquiry, a code is most often a word or a short phrase that
symbolically assigns a summative, salient, essence-capturing, and evocative attribute for a portion of
language-based or visual data (S aldaña, 2013). Below is an example of a message hidden in codes (in a
form of a riddle):

“I stand alone before fifty in Rome. None came before five, the three inverted, and you will be the last.”
Message: _____________________________

Activity:

Write the following Hindu-Arabic (Decimal) to Roman numerals.


1. 9 4. 98
2. 200 5. 1457
3. 501

How to convert decimal to Roman numerals


https://www.youtube.com/watch?v=x9AgrIFZjfo

How to convert Roman numerals to decimal


https://www.youtube.com/watch?v=MOIJxae_7Pk

Analysis:

1. What are the seven Roman numeral symbols that have a fixed integer value?
2. How do you convert Hindu-Arabic to Roman numerals?
3. Can we apply the same methods or rules that we us e in Roman numerals to the other number
system?

Abstraction:

People may use other words or phrases to code messages since in qualitative data analysis,
coding is not a precise science. Different cultures use different codes or symbols for expressing numbers.
Below are some examples.

SY 2020-2021 | GEC104 Chapter 2| The Beauty of Codes 1


CHA PTER 2. THE BEA UTY OF CODES

Hieroglyphic Numeral System

During the ancient times, hieroglyphics (or sacred writings ) were used by the E gyptians in their
writing system. The E gyptian counting system was comprehensive compared to their contemporaries.
They even had a symbol to represent infinity.

See this link for additional information about hieroglyphic.


https://www.youtube.com/watch?v=Ld0zuPAtjJA

Chinese Numeral System

Chinese writing is basically logographic writing system, one of the world’s great writing systems. It
is now recognized that the system represents the Chinese language by means of a logographic script.
Each graph or character corresponds to one meaningful unit of the language, not directly to a unit of
thought (https://www.britannica.com/topic/Chinese-writing).

Traditional Chinese Numeral System


https://www.youtube.com/watch?v=mxbwF6sAsG0

10 100 1000 10,000 100,000,000


Chinese Numerals

SY 2020-2021 | GEC104 Chapter 2| The Beauty of Codes 2


CHA PTER 2. THE BEA UTY OF CODES

Roman Numerals

(https://www.google.com/search?tbm=isch&q=roman+ number+system&chips .)

Binary Number System

The binary system is a number system that uses only two values (0,1; on, off) to represent codes
and data. Since zeros and ones can be easily represented by two voltages, the binary system is the
foundation on which digital technology is built. Every digital computer whether a pocket calculator or a
mainframe uses the same binary notation.

(http://www.businessdictionary.com/definition/binary-system.html)

How to convert binary to decimal


https://www.youtube.com/watch?v=VLflTjd3lWA

How to convert decimal to binary


https://www.youtube.com/watch?v=rsxT4FfRB aM

SY 2020-2021 | GEC104 Chapter 2| The Beauty of Codes 3


CHA PTER 2. THE BEA UTY OF CODES

Steps to Convert from Decimal to Binary

If you don't have a calculator to hand, you can easily convert a decimal number to binary using the
remainder method. This involves dividing the number by 2 recursively until you're left with 0, while taking
note of each remainder.

1. Write down the decimal number.

2. Divide the number by 2.

3. Write the result underneath.

4. Write the remainder on the right hand side. This will be 0 or 1.

5. Divide the result of the division by 2 and again write down the remainder.

6. Continue dividing and writing down remainders until the result of the division is 0.

7. The most significant bit (MSB) is at the bottom of the column of remainders and the least significant
bit (LSB) is at the top.

8. Read the series of 1s and 0s on the right from the bottom up. This is the binary equivalent of the
decimal number.

SY 2020-2021 | GEC104 Chapter 2| The Beauty of Codes 4


CHA PTER 2. THE BEA UTY OF CODES

Steps to Convert Binary to Decimal

Converting from binary to decimal involves multiplying the value of each digit (i.e. 1 or 0) by the value of
the placeholder in the number

1. Write down the number.

2. Starting with the LSB, multiply the digit by the value of the place holder.

3. Continue doing this until you reach the MSB.

4. Add the results together.

Source: https://owlcation.com/stem/How-to-Convert-Decimal-to-Binary-and-Binary-to-Decimal

Barcodes

A barcode is an optical, machine-readable, representation of dat a. Traditional barcodes


systematically represent data by varying the widt hs and spacings of parallel lines, and may be referred to
as linear or one dimensional (1D). Lat er, two -dimensional (2D) variants were developed, using rectangles,
dots, hexagons and other geometric patterns, called matrix codes or 2D barc odes, although they do not
use bars as such. Initially, barcodes were only scanned by special optical scanners called barcode
readers. Later application software became available for devices that could read images, such as
smartphones with cameras. Barcode was invented by Norman Joseph W oodland and Bernard Silver and
patented in the United States in 1952.

SY 2020-2021 | GEC104 Chapter 2| The Beauty of Codes 5


CHA PTER 2. THE BEA UTY OF CODES

Barcodes became commercially successful when they were used to automate supermark et
checkout systems, a task for which they have become almost universal. Their use has spread to many
other t asks that are generically referred to as Aut omatic Identification and Data Capture (A IDC). The very
first scanning of the now-ubiquitous Universal Product Code (UP C) barcode was on a pack of Wrigley
Company’s Juicy Fruit Gum in June 26, 1974. Quick Response (QR) codes, a specific type of 2D barcode,
have recently become very popular. Since then, barcoding has become an efficient way of translating
data instantaneously and accurately. It is used for aut omated dat a collection. It eliminates the o ccurrence
of human error since through t he use of a bar scanner, transmitting data is fast and reliable and t akes
lesser time than entering them manually. Here are some types of linear or one-dimensional (1D)
barcodes.

UPC EAN- 13
Pharmacode

POSTNET Pessey ITF-14

Here are some types of matrix or two-dimensional (2D) barcodes.

Aztec MaxiCode Quick Response (QR) PDF -


147

Because of error correction capability, it is possible to create artistic barcodes that incorporate colors,
logos, and other feat ures, making them readable or attractive to the human eye, but still scan correctly.
That is why there are also some products that have customized barcodes.

SY 2020-2021 | GEC104 Chapter 2| The Beauty of Codes 6


CHA PTER 2. THE BEA UTY OF CODES

Some customized barcodes

Identification Numbers

Identification numbers are used to identify individual items, specific products, people, account
or doc uments. These numbers are useful for the easy recognition or direction of materials and for tracking
and inventory purposes of products or doc uments (Kirtland, 2000). A numeric identification number is a
single positive number or a string of digits, sometimes separated by dashes or spaces. An example of this
is the Tax Identification Number (TIN). An alphanumeric identification number has a string of digits,
letters or/and even other symbols. The vehicle plate is an example of an alphanumeric identification
number.
A check digit or a check sum is used to verify errors on identification numbers. In general, a
check digit is a single number that is generated using the other charac ters from the identification number.
Different identification numbers use different check digit schemes.

Universal Product Code

A Universal Product Code (UPC) is the 12-digit identification number of a retail item. Nearly
every item that we purchas e from a supermark et and department store has a UP C on it. These barcodes
were originally created to help grocery and department stores speed up the checkout process and keep
track of inventory. The system quickly spread to many other retail products. A manufacturer applies to the
Uniform Code Council (UCC) for permission to join the UPC system and pays an annual fee. The UCC
issues the manufacturer an identification number and provides guidelines on how to use it. The
manufacturer designates a UP C coordinator who is responsible for assigning item numbers to products,
making sure that the s ame code is not used on more than one product, retiring codes as products are
removed from the product line. The UPC is referred as UP C-A in the United Stat es. A 12-digit UPC
d1d2d3d4d5 d6d7d8d9 d10d11d12 is properly written as d1 d2d3d4d5d6 d7d8d9d10d11 d12 or
d1d2d3d4d5d6d7d8d9d10d11d12. The following table lists the different values of d1.

d1 Specific Use
0 General groceries
2 Meat products
3 Drug and health products
4 Non-food items
5 Coupons
6, 7 Other items
1, 8, 9 Reserved for future use

SY 2020-2021 | GEC104 Chapter 2| The Beauty of Codes 7


CHA PTER 2. THE BEA UTY OF CODES

The second set consists of five digits d2d3d4d5d6 identifies the manufacturer while the third set of five
digits d7d8d9d10d11 identifies the product. In the bar code above, 0 is the type of product, 20357 is the
manufacturer identification number and 12268 is the item number. In general, every item that the
manufacturer sells, as well as every size of the packaging and every repackaging of the item, needs a
different item c ode. For ex ample, a 12 -ounce can of soda needs a different item number than a 16-ounce
bottle version, as does a 6-pack of 12-ounce cans, a 12-pack, a 24-can case, and so on. It is the
responsibility of the UPC coordinator t o keep track of all these numbers. The last digit d12 is the c heck
digit. This digit lets the system determine if it scanned the number correctly or not. Given the 11 -digit
string d1d2d3d4 d5d6d7d8 d9d10d11, the check digit d12 is added so that 3d1 + d2 + 3d3 + d4 + 3d5 + d6 + 3d7 +
d8 + 3d9 + d10 + 3d11 + d12 is divisible by 10. Each time the scanner scans an item, it performs this
calculation. If t he check digit it calculates is different from the check digit it reads, the scanner knows that
something went wrong and the item needs to be rescanned.

Examples
1. The UPC 0-53600-10054-0 (or sometimes written as 0 53600 10054 0) is valid since 3(0)
+ 5 + 3(3) + 6 + 3(0) + 0 + 3(1) + 0 + 3(0) + 5 + 3(4) + 0 = 40 is divisible by 10.

2. Find the check digit of the UPC 7-70832-30854-x.

Solution: Note that 3(7) + 7 + 3(0) + 8 + 3(3) + 2 + 3(3) + 0 + 3(8) + 5 + 3(4) = 97. Thus,
we add 3, which is the smallest positive integer less than 10, so that the sum becomes
100, which is divisible by 10. Hence, x = 3.

3. The UPC of Kellogg's Corn Flakes Cereal 24 oz (Pack of 14) is 0 38000 00127 7. Determine
how a barcode scanner would detect the error if the above -mentioned code was entered into the
computer as 0 58000 00127 7.

Solution: Note that 3(0) + 5 + 3(8) + 0 + 3(0) + 0 + 3(0) + 0 + 3(1) + 2 + 3(7) + 7 = 62,
which is not divisible by 10. Another solution is that if we only consider the first
11 digits, we have 3(0)+5 + 3(8) + 0 + 3(0) + 0 + 3(0) + 0 + 3(1) + 2 + 3(7) = 55,
and by adding 5, we get 70 which is divisible by 10. But 5 is not the check digit.

International Article Number

The International Article Number (also known as European Article Number or EAN) is a
numbering system used in global trade to identify a specific retail product type, in a specific packaging
configuration, from a specific manufacturer. This numbering system includes EAN-2, EAN-5, EAN-8 and
EAN-13. The most commonly used EAN code is the 13 -digit EAN-13 code, a s uperset of the original 12-
digit Universal Product Code of America (UPC-A). The UPC-A format barcodes have in tradition been
used in the USA, whereas EAN-13 format barcodes have been used throughout the rest of the world.
Nowadays, the majority of stores thro ughout the world accept barcodes in either format. However there
might be some older systems that only accept one or the other. This means that if your product is being
sold in the USA, the UP C-A format barcodes are best, however if your product is international, or sold in a
country other than the USA, an EAN-13 barcode is best. An EAN-13 barcode is consist of the country
code, manufacturer code, product code and check digit, respectively. Most of the products here in the
Philippines use EAN-13 barcodes. Our country code is 480.
Given the 12-digit string d1d2d3d4 d5d6d7d8 d9d10d11d12, the check digit d13 is added so that d1 + 3d2
+ d3 + 3d4 + d5 + 3d6 + d7 + 3d8 + d9 + 3d10 + d11 + 3d12 + d13 is divisible by 10. An EAN-13 code is usually
written as d1d2d3d4d5d6d7d8d9d10d11d12d13 or d1 d2d3d4d5d6d7 d8d9d10d11d12d13.
Remark: It can be observed that in a UP C-A code, the odd-numbered digits are multiplied by 3 while in
an EAN-13 code, the even-numbered digits are multiplied by 3.

SY 2020-2021 | GEC104 Chapter 2| The Beauty of Codes 8


CHA PTER 2. THE BEA UTY OF CODES

Quick Response Codes

The Quick Response (QR) code was invent ed in Japan by Toyota subsidiary Denso-Wave in
1994 to track vehicles during the manufacturing process. It was designed to allow high -speed component
scanning. It has since become one of the most popular product tagging schemes.
Unlike the one-dimensional UP C that is scanned by a narrow beam of light to extract data, the
QR code is detected as a two-dimensional digital image by a semi-conductor image sensor. The sensor
locates the three distinctive squares at the corners of the image, and uses a smaller square near the 4th
corner to normalize the image for size, orientation and angle of viewing. The smaller dots are then
converted into binary numbers and their validity checked with error-correcting code.
QR codes have bec ome common in consumer advertising. Smartphone users can install an
application (app) whic h scans a displayed code, converts the code to a URL, and opens the smartphone’s
browser to the website of the company, store or product associated with the code.
The amount of data that can be stored in the QR code symbol depends on the data type, version and
error correction level. The higher the error correction level, the less storage capacity. The following table
lists the approximate error correction capability at each four levels.

Level No. of codewords that


can be restored
L (Low) 7
M (Medium) 15
Q (Quartile) 25
H (High) 30

Examples of QR codes

Nestea QR code Sivatel Bangkok WeChat QR code Tag Heuer QR code

Application:
1. Write the following in Roman numerals.
a. 795 c. 598
b. 2 628 d. 4 233

2. Write the following in Hindu-Arabic (Decimal).


a. DCLII c. DCCCXXXV
b. MMMCDLXXVIII d. ̅̅̅CCI

3. Write the following in the ancient Egyptian hieroglyphic numeral system.


a. 1,152,394 c. MCMLXXXV II
b. 2,487,109 d. MMMCDLXIX

SY 2020-2021 | GEC104 Chapter 2| The Beauty of Codes 9


CHA PTER 2. THE BEA UTY OF CODES

4. Give the equivalent of the following binary numbers in decimal.


a. 1101102 c. 1100112
b. 1110002 d. 1001112

5. Give the equivalent of the following binary numbers in decimal


a. 95 c. 378
b. 458 d. 125

6. Give the importance of barcodes.

7. Suppose that the packaging of a certain grocery item was damaged in such a way that the
5th digit of a UP C-A c ode was scratched off but the remaining 11 remaining digits (from d1 to
d12) shows 8-8072-30358-4. Determine the correct UPC number.

8. Show that the EAN-13 barcode of the following Philippine made products are valid.
(a) Goldilocks PinoyDeli Laing (150 g): 4-800111-009901
(b) Doctor J 70% Solution Ethyl Alcohol (500 mL): 4-809012-648165
(c) Mr. Chips Nacho Cheese Flavor (100 g): 4-800016-653094

9. . Which of the following are valid UPCs? Support your answer.


(a) 0-51000-02562-4 (c) 0-70501-09110-4
(b) 0-51000-02526-4 (d) 1-23004-24410-7

10. The UPC for a certain product is 0 51000 02526 5. Explain why the errors in the following
misread versions of this UPC would not be detected as errors.
(a) 0 51000 02625 5 (b) 0 50000 05526 5

Assessment:

Take the quiz on moodle.

References

Kirtland, J. (2000). Identification numbers and check digit schemes (Classroom resource
materials). American Mathematical Society.

Nocon, E. and Noc on, R. (2018). Essential Mathematics for the Modern World. Quezon City: C&E
Publishing.

Ragasa, C., Evangelista, J. and Baltazar, E. (2018) Mathematics in the Modern World.
Quezon City: C&E Publishing.

Saldaña, J. (2013). The coding manual for qualitative researches. Los Angeles: SAGE
Publications

SY 2020-2021 | GEC104 Chapter 2| The Beauty of Codes 10

You might also like