Professional Documents
Culture Documents
MMW Module 5 1 Binary Numbers Codes
MMW Module 5 1 Binary Numbers Codes
References 24
Introduction
Codes were already around since ancient times. A code is a symbolic way to represent
information. In qualitative inquiry, a code is most often a word or short phrase that
symbolically assigns a summative, salient, essence capturing, and or evocative attribute for
a portion of language-based or visual data (Saldana, 2013).
During the ancient times, codes were already used by humans. Hieroglyphics or “sacred
writings” are codes used by ancient Egyptians in their writing system. Roman numerals
were developed to easily determine the prices of commodities and services rendered by the
Romans. Roman numerals were used throughout Europe up until the 1600s. The more
recently invented codes are musical scores, genetic codes, and the DNA or deoxyribonucleic
acid.
1
Paulinian A rmation
“As a Christ-centered Paulinian, I am an engaging, trustworthy, team builder, and
mentor, fostering community through active collaboration.”
Learning Outcomes
During the learning engagement, you should be able to
● decipher binary codes,
● use coding schemes to encode and decode different types of information for
identification, privacy, and security purposes, and
● exemplify honesty and integrity when using codes for security purposes.
2
Learning Activities
Processing
Binary Numbers
In coding, when numbers, letters, or words are represented by a specific group of symbols,
it is said that the numbers, letters, or words are being encoded. The group of symbols is
called a code. The digital data is represented, stored, and transmitted as a group of binary
bits. This group is also called binary code. The binary code is represented by a number as
well as an alphanumeric letter.
Binary code represents text, computer processor instructions, or any other data using a
two-symbol system. The two-symbol system used is often 0 and 1 from the binary number
system. The binary code assigns a pattern of binary digits, also known as bits, to each
character, instruction, etc. It is a system of representing letters, numbers, or other
characters using binary notation.
Computers work in binary code. Information is coded using 0s and 1s. Each 0 or 1 is called a
bit. In the early years of computer development, different computer companies applied the
binary system in their own way. The code for the letters in the word “cat” was often different
in different brands of computers. Eventually, a set of standards was developed. Computer
manufacturers agreed to use one code called the ASCII (American Standard Code for
Information Interchange). ASCII is an 8-bit code. That is, it uses eight bits to represent a
letter or a punctuation mark. Eight bits are called a byte. A binary code with eight digits,
such as 1101 10112 , can be stored in one byte of computer memory. The word “CAT” in a
word processor becomes 0100 00112 , 0100 00012 , and 0101 01002 . The word “cat” is
0110 00112 , 0110 00012 , and 0111 01002 .
3
Table 1. ASCII Code
A bit is a binary digit that is 1 or 0. In a digital computer, data and instructions are encoded
as bits. Each digit of a binary number is called a bit. A binary number with eight bits (i.e.
digits) is called a byte.
The following are all examples of binary numbers:
4
( ) ( ) ( )
786 = 7×102 + 8×101 + 6×100 = 700 + 80 + 6
However, in the binary number system, the symbols 1 and 0 are the only integers that can
be represented. In representing an integer, read from the right to the left.
This is expressed mathematically for each of the first five positions as
For example, the value of the combination of symbols 435 is determined by adding the
weight of each position as
( ) ( ) (
= 4×102 + 3×101 + 5×100 )
5
For example, the value of the combination of symbols, 249.34 is determined by adding the
weight of each position as
4 3 2 1
Numbering (exponent) 0
The first row (labeled “digits”) contains the digits from the binary number; the second row
(labeled “numbering”) contains the power of 2 (the base) corresponding to each digit. I will
6
( ) ( ) ( ) ( ) ( )
110112 = 1 24 + 1 23 + 0 22 + 1 21 + 1 20 = 1 (16) + 1 (8) + 0 (4) + 1 (2) + 1 (1) = 16 + 8 + 0 + 2 + 1 = 2710
Thus, 110112 converts to 2710 .
Example 2. Convert the binary numbers 11011.012 to their decimal equivalents.
29 / 2 14 1 1’s
14 / 2 7 0 2’s
7 / 2 3 1 4’s
3 / 2 1 1 8’s
1 / 2 0 1 16’s
We need to stop when the quotient is now zero. By reading upward (the first digit in the
binary is 16’s), we obtain 2910 = 111012 .
7
29 / 2 14 1 1’s
14 / 2 7 0 2’s
7 / 2 3 1 4’s
3 / 2 1 1 8’s
1 / 2 0 1 16’s
2910 = 111012
The fraction part is 0.25. Convert to binary format.
0.25 x 2 0.5 0
0.5 x 2 1.0 1
We need to stop when the product is now 1. By reading downward, we obtain 0.2510 = 012 .
Therefore, 29.2510 is equal to 11101.012 .
1 1 1 1 01101 + 01011 11000
Binary Subtraction
In subtracting binary numbers, we also use the fact that the difference of the numbers must
be one and zero only. Please note that we are limited to subtracting bigger numbers by
smaller numbers.
Binary subtraction is just as simple as addition. Subtraction of one bit from another obeys
the following four basic rules:
● the difference of 0 and 0 is 0;
● the difference of 1 and 0 is 1;
● the difference of 1 and 1 is 0; and
● the difference of 0 and 1 is 1 (we need to borrow 1).
Example: Suppose we will subtract 11102 and 10012 .
0 10 1110 1001 101
When doing subtraction, it is sometimes necessary to borrow from the next higher-order
column. The only time it will be necessary to borrow is when we try to subtract 1 from 0. In
this case 1 is borrowed from the next higher-order column, which leaves 0 in that column
and creates 10.
9
1001 ×1110 0000 1001 1001 1001 1111110
Binary Division
Division in the binary number system employs the same procedure as division in the
decimal system. To divide binary numbers, we have to take a look at our divisor and count
the length of the bits and divide like the ones presented below.
111 11/10101 011 100 11 11 11 0
10
11
10000001 111011001
1100001100 1100000
12
10010001 101011001
1100101100 11010101
2. Odd Parity
● If the data has an odd number of 1’s, the parity bit is 0.
Example:
1001001 10101011
10011101 11010101
● If the data has an even number of 1’s, the parity bit is 1.
Example:
1001011 10010101
110001100 10101010
Cyclic Redundancy Check (CRC)
A cyclic code is a linear (n, k ) block code with the property that every cyclic shift of a
codeword results in another codeword. Here, k indicates the length of the message at
transmitter (the number of information bits), n is the total length of the message after
adding check bits (actual data and the check bits), and (n, k ) is the number of check bits.
The codes used for cyclic redundancy check by error detection are known as CRC codes
(cyclic redundancy check codes). Cyclic redundancy check codes are shortened cyclic codes.
These types of codes are used for error detection and encoding. They are easily
implemented using shift registers with feedback connections. That is why they are widely
used for error detection on digital communication. CRC codes provide an effective and high
level of protection.
13
Check Sum
Checksums are similar to parity bits except that the number of bits in the sums is larger
than the parity and the result is always constrained to be zero. That means if the checksum
is zero, error is detected. A checksum of a message is an arithmetic sum of codewords of
certain length. The sum is stated by means of 1’s complement and stored or transferred as
a code extension of the actual codeword. At receiver, a new checksum is calculated by
receiving the bit sequence from the transmitter.
Hamming Code
Hamming code is a set of error correction that can be used to detect and correct bit errors
that can occur when computer data is moved or stored. Hamming code is named after R.W.
Hamming of Bell Labs.
14
2P ≥n + P + 1
Here, n represents the number of bits in a data string and P represents the number of
parity bits.
Where to Place these Parity Bits?
The parity bits have to be located at the positions of powers of 2, i.e., at 1, 2, 4, 8, and 16 etc.
Therefore the codeword after including the parity bits will be like this:
D7 , D6 , D5 , P 4 , D3 , P 2 , P 1
Here, P 1 , P2, and P 3 are parity bits. D1 D7 are data bits.
15
1 1 0 1
Data Bits (Dn )
0 0 1
Parity Bits (P n )
Step 3. Determine the parity bits.
For P 1 : 3, 5, and 7 bits are having three 1’s, so for even parity, P 1 = 1 .
For P 2 : 3, 6, and 7 bits are having two 1’s, so for even parity, P 2 = 0 .
For P 3 : 5, 6, and 7 bits are having two 1’s, so for even parity, P 3 = 0 .
16
Formation
Decipher the code into a sentence and vice versa by referring to the binary code table (Table
1).
I. Decipher the code to form a sentence by referring to the binary code table.
1. 00100010 01001101 01000001 01010100 01001000 00100000 01001001
01010011 00100000 01000111 01010010 01000101 01000001 01010100
00100010
2. 01001001 00100000 01001100 01001111 01010110 01000101 00100000
01011001 01001111 01010101
3. 00110111 00101101 01100010 01101001 01110100
4. 00100010 00100011 00110001 00110100 00110011 00100010
5. 01000001 01101101 01100101 01110010 01101001 01100011 01100001
01101110 0100000 01010011 01110100 01100001 01101110 01100100
01100001 01110010 01100100 00100000 01000011 01101111 01100100
01100101 00100000 01100110 01101111 01110010 00100000 01001001
01101110 01100110 01101111 01110010 01101101 01100001 01110100
01101001 01101111 01101110 00100000 01001001 01101110 01110100
01100101 01110010 01100011 01101000 01100001 01101110 01100111
01100101 00100000 00101000 01000001 01010011 01000011 01001001
01001001 00101001
II. Make a code using a binary code table.
“Mathematics in the Modern World”
III. On a separate sheet of paper, write a short message in ASCII. Exchange messages
with a partner/ group and decode each other’s messages.
17
Convert binary numbers to decimal equivalents and vice versa, and solve binary numbers/
decimal equivalents using four fundamental operations. Show your solution.
I. Convert the following binary numbers to decimal equivalents.
1. 00110022
2. 0000112
3. 0111002
4. 11100.0012
5. 110011.100112
II. Convert the following decimal numbers to their binary equivalents.
1. 64
2. 128
3. 100
4. 34.75
5. 25.25
III. Compute the different fundamental operations.
A. Find the sum.
1. 10102 and 01102
2. 11011 and 10010
3. 15 + 12 in binary form
18
2. How can mathematics be a tool to explain the nature of binary numbers in computer
systems?
19
Identify the even or odd parity bit and detect the hamming code. Show your solution.
I. Consider the following set of bytes transferred from CD-ROM to hard disk. What
should be the parity bits when using even parity and odd parity? Determine the
number of parities in the following messages.
0 0 1 0 1 1
1 0 0 1 0 0
1 1 1 1 0 1
1 1 0 1 0 0
0 0 0 1 0 0
1 0 1 1 1 0
0 0 0 0 0 0
1 0 0 1 0 0
1 1 1 1 0 1
1 1 0 1 0 0
0 0 0 1 0 0
1 0 1 1 1 1
20
2. Did parity check unable to detect errors in some sets of data? Why?
3. How do you identify errors in data bit?
Synthesis
The utility of mathematics goes beyond the unexpected. One of the utilities is the
development of the codes and ciphers that are useful to everybody. There are coding
schemes that are used to encode and decode different types of information for
identification, privacy, and security purposes. In the computer systems, those are the binary
codes.
21
Assessments
Direction: Choose the letter of the correct answer.
1. Which of the following does not give odd parity bits of 1?
a. 100001111
b. 101010101
c. 110011001
d. 110110110
2. Which of the following is the sum of 1011, 1101, and 1011?
a. 100101
b. 100011
c. 010011
d. 011100
3. Which of the following is not an example of code?
a. Morse code
b. Identification number
c. Prisoner's Dilemma
d. Cipher
4. Which of the following is the special keyboard shortcut for “scroll to last page of
document”?
a. Control Page Up
b. Page Up
c. Page Down
d. Control Page Down
22
Assignment
Research about linear programming and its method, and prepare one example.
Re ection Guide
1. What have I LEARNED this day that has helped me do all aspects of this better?
2. What have I DONE this week that has made me better at doing all aspects of this?
3. How can I IMPROVE at doing all aspects of this?
Expanded Opportunity
Identify and show some error detection in the computer system. How do you identify the
error?
23
References
Alejan, R., et al. Mathematics in the Modern World. Malabon City: Mutya Publishing House,
2018.
Baltazar, Ethel, Carmelita Ragasa, and Justina Evangelista. Mathematics in the Modern
World. Quezon City: C and E Publishing, Inc., 2018.
Budd, Chris. “Error correcting codes.” Plus Magazine. Retrieved from
https://plus.maths.org/content/error-correcting-codes (accessed 16 August 2020)
Electronics Hub. “Error Correction and Detection Codes.” Retrieved from
https://www.electronicshub.org/error-correction-and-detection-codes/#Types_Of_E
rrors (accessed 16 August 2020)
Guru 99. “Hamming Code: Error Correction Examples.” Retrieved from
https://www.guru99.com/hamming-code-error-correction-example.html (accessed
16 August 2020)
Hamer, F., R. Horan, and M. Lavelle. “Binary Numbers 2.” Retrieved from
https://www.plymouth.ac.uk/uploads/production/document/path/3/3725/Plymout
hUniversity_MathsandStats_binarynumbers2.pdf (accessed 16 August 2020)
Intel Corporation. “Student Handout: ASCII Computer Code.” The Journey Inside.
Retrieved from
https://www.intel.ca/content/dam/www/program/education/us/en/documents/the-
journery-inside/digital/tji-digital-info-handout4.pdf (accessed 16 August 2020)
Nocon, Rizaldi and Ederlina Nocon. Essential Mathematics for the Modern World. Quezon
City: C and E Publishing, Inc., 2018.
24
Pbte.edu. “Chapter 10 Number Systems and Arithmetic Operations.” Retrieved from
https://www.pbte.edu.pk/text%20books/dae/math_123/Chapter_10.pdf (accessed
16 August 2020)
Poudel, Subash. “Binary and Decimal Number System” Science HQ. Retrieved from
https://www.sciencehq.com/computing-technology/binary-and-decimal-number-sy
stem.html (accessed 16 August 2020)
Raut, Nitya. “Error Correcting Codes - Hamming Codes.” Tutorialspoint. Retrieved from
https://www.tutorialspoint.com/error-correcting-codes-hamming-codes (accessed
16 August 2020)
Thakur, Arjun. “What are Error-Detecting Codes?” Tutorialspoint. Retrieved from
https://www.tutorialspoint.com/what-are-error-detecting-codes (accessed 16
August 2020)
Wikipedia. “Error detection and correction.” Retrieved from
https://en.wikipedia.org/wiki/Error_detection_and_correction (accessed 16 August
2020)
Yadav, Chandu. “Decimal Number System” Tutorialspoint. Retrieved from
https://www.tutorialspoint.com/what-are-error-detecting-codes (accessed 16
August 2020)
25