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

 

Module 4B: Codes  


 
Table of Contents 
 
Introduction 1 
Paulinian Essential Elements 2 
Paulinian A rmation 2 

Topic 1: Binary Numbers 2 


Learning Outcomes 2 
Learning Activities 3 
Processing 3 
Binary Numbers 3 
Decimal Number System (Base 10) 5 
Operations of Binary Numbers 8 
Errors and Error Correction 10 
Error Detecting Codes 11 
Types of Error Detection 12 
Hamming Code 14 
Formation 17 
Activity 1: Decipher Me! 17 
Activity 2: Convert Me! 18 
Activity 3: Bit Me! 20 
Synthesis 21 
Assessments 22 
Assignment 23 

Re ection Guide 23 

Expanded Opportunity 23 

References 24 
 
 
 
 

 
   

Module 4B: Codes 


 
 

  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 
 
   

Module 4B: Codes 


 
 
Computers  represent  information  using  bits.  A  bit  is  a  symbol  with  two  possible  values, 
namely  0  (zero)  and  1  (one).  The meaning of the word bit comes from “binary digit” because 
zeros  and  ones  are  the  digits  used  in  binary  representations  of  numbers.  The  well-known 
statistician  John  Tukey  introduced  this  terminology in 1946. A bit can be used to represent a 
truth  value.  There  are  two  truth  values,  namely,  true,  when  the  statement  is  correct,  and 
false,  if  otherwise.  As  customarily  done,  we  use  a  1  bit  to  represent  true  (T)  and  a  0  bit  to 
represent false (F). 
 

  Paulinian Essential Elements 


 
Engaging, Trustworthy, Team Builders, and Mentors who 
● clarify  at  the  outset  the  substance  and  intent  of  all  agreements  and  commitments 
made, making every effort to fulfill them and supporting others to do the same; and 
● willingly  and  openly  share  relevant  insights,  observations,  expertise,  guidance,  and 
support with less experienced colleagues. 
  

  Paulinian A rmation 
“As  a  Christ-centered  Paulinian,  I  am  an  engaging,  trustworthy,  team  builder,  and 
mentor, fostering community through active collaboration.” 
 
 

Topic 1: Binary Numbers   


 

  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 
 
   

Module 4B: Codes 


 
 

  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 
 
   

Module 4B: Codes 


 
 

 
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: 

101012 01010102 10111101012 01101011102


 
How  the  bits  are  physically  represented  within  a  computer  system  is  determined  by 
technology.  Computer  hardware  today  relies  on  the  state  of  an  electronic  circuit  to 
represent a bit. For example, 101101 is a 6-bit number as it has six binary digits (0s and 1s). 
 
In  computing  and  telecommunications,  binary  codes  are  used  for  various  methods  of 
encoding  data  such as character strings into bit strings. Those methods may use fixed-width 
or  variable-width  strings.  In a fixed-width binary code, each letter, digit, or other character is 

 
  4 
 
   

Module 4B: Codes 


 
 
represented  by  a  bit  string  of  the  same  length.  That  bit  string,  interpreted  as  a  binary 
number,  is usually displayed in code tables in octal, decimal, or hexadecimal notation. There 
are many character sets and many character encodings for them. 
 

Decimal Number System (Base 10) 


In  this  number  system,  the  digit  0 to 9 represents numbers. As it uses 10 digits to represent 
a  number,  it  is  called  the  base  10  number  system.  Each  digit  has  a  value  based  on  its 
position  called  place  value.  The  value  of  a  position  increases  10  times  as  we  move  from 
right  to  left  in  the  number.  The  word  “Deci”  means  10;  therefore,  there  are  ten  numbers 
(digits) in the decimal number system. The valid numbers in a base 10 number system are: 

0,  1,  2,  3,  4,  5,  6,  7,  8,  9


 
All  number  systems  have  a  “base.”  The  base  is  the same as the number of valid numbers in 
the  system.  Since  the  decimal  number  system  has  10  valid  numbers,  it  is  a  “base  10” 
number system. 
 
For example, the number to be deciphered is 786. 

( ) ( ) ( )
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 

104 103 102 101 100

ten thousands  thousands  hundreds  tens  units 

 
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 
 
   

Module 4B: Codes 


 
 
which can be written as 

= (4×100) + (3×10) + (5×1) or 400 + 30 + 5 = 435  


 
The  position  to  the  right  of  the  decimal  point  carry  a  positional  notation  and  a 
corresponding  weight  as  well.  The  exponents  to  the  right  of  the  decimal  point  are negative 
and  increase  in  integer  steps starting with  ­ 1  . This is expressed mathematically for each of 
the first four positions as 
 

10­1   10­2   10­3   10­4  

tenths  hundredths  thousandths  ten thousandths 

 
For  example,  the  value  of  the  combination  of  symbols,  249.34  is  determined  by  adding  the 
weight of each position as 

= 2×102 + 4×101 + 9×100 + 3×10­1 + 4×10­2 = 200 + 40 + 9 + 0.3 + 0.04 = 249.34  


( ) ( ) ( ) ( ) ( )
 
Conversion of Binary Numbers to Decimal Numbers 
Converting  binary  to  decimal  numbers  is  fairly  simple,  as  long  as  you  remember  that  each 
digit in the binary number represents a power of two. 
 
Example 1. Convert 110112 to its corresponding base ten number. 
 
I  will  list  the digits in order, as they appear in the number they’ve given me. Then, in another 
row, I’ll count these digits off from the right, starting with zero. 
 
1  1  0  1 
Digits  1 

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 
 
   

Module 4B: Codes 


 
 
use this listing to convert each digit to the power of two that it represents. 
 

( ) ( ) ( ) ( ) ( )
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. 
 

11011.012 = 1 24 + 1 23 + 0 22 + 1 21 + 1 20 + 0 2­1 + 1 2­2 = 1 (16) + 1 (8) + 0 (4) + 1 (2) + 1 (1) + 0 (0.5) + 1


( ) ( ) ( ) ( ) ( ) ( ) ( )
 
Thus, 11011.012 converts to 27.2510 . 
 
Can you do the reverse? Now let us try decimal to binary numbers conversion. 
In  converting  decimal  numbers  to  binary,  the  computational  process  is  to  show  successive 
division by 2’s with the remainders recorded. 
 
Example 1. Write the decimal 2910 as binary numbers. 
 

Division by 2  Quotient  Remainder  Place of Bits 

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 
 
   

Module 4B: Codes 


 
 

Example 2. Write the decimal 29.2510 as binary numbers. 


 

Division by 2  Quotient  Remainder  Place of Bits 

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. 
 

Multiply it by 2  Product  Integer Part 

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 . 
 

Operations of Binary Numbers 


Arithmetic  operations  in  number  systems  are  usually  done  in  binary  because  designing  of 
logic  networks  is  much  easier  than  decimal.  Binary  arithmetic  includes  the  basic  arithmetic 
operations  of  addition,  subtraction,  multiplication,  and  division.  The  following  sections 
present  the  rules  that  apply  to  those  operations  when  they  are  performed  on  binary 
numbers. 
 
 
  8 
 
   

Module 4B: Codes 


 
 
Binary Addition 
Binary  addition  is  performed  in  the  same  way  as  addition  in  the  decimal  system  and  is,  in 
fact, much easier to master. Binary addition obeys the following four basic rules: 
● the sum of 0 and 0 is 0; 
● the sum of 1 and 0 is 1; 
● the sum of 0 and 1 is 1; and 
● the sum of 1 and 1 is 10. 
 
Example: The sum of 011012 and 0100112 is 
 

     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 
 
   

Module 4B: Codes 


 
 
Binary Multiplication 
Binary  multiplication  is  performed  in  the  same  manner as decimal multiplication. It is much 
easier  since  there  are  only  two  possible results of multiplying two bits. Binary multiplication 
obeys the following three basic rules: 
● the product of 0 and 0 is 0; 
● the product of 1 and 0 is 0; and 
● the product of 1 and 1 is 1. 
 
Example: Suppose we will subtract 11102 and 10012 . 
 

    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     
 

Errors and Error Correction 


Error  correction  is  the  process  of  detecting  errors  in  transmitted  messages  and 
reconstructing  the  original  error-free  data.  Error  correction  ensures  that  corrected  and 
error-free messages are obtained at the receiver side. 
 
Systems  capable  of  requesting  the  retransmission  of  bad  messages  in  response  to  error 
detection  include  an  automatic  repeat  request  (ARQ)  processing  in  their  communication 
software  package.  They  use  acknowledgments,  negative  acknowledgment  messages,  and 
timeouts  to  achieve  better  data  transmission.  ARQ  is  an  error  control  (error  correction) 
method  that  uses  error  detection codes and positive and negative acknowledgments. When 
the  transmitter  either  receives  a  negative  acknowledgment  or  a  timeout  happens  before 
acknowledgment is received, the ARQ makes the transmitter resend the message. 

 
  10 
 
   

Module 4B: Codes 


 
 
Error-correcting  code  (ECC)  or  forward  error  correction  (FEC)  is  a  method  that  involves 
adding  parity  data  bits  to  the  message.  These  parity  bits  will  be  read  by  the  receiver  to 
determine  whether  an  error  happened  during  transmission  or  storage.  In  this  case,  the 
receiver  checks  and  corrects  errors  when  they  occur.  It  does  not  ask  the  transmitter  to 
resend the frame or message. 
 
Error  correction  is  a  step  better than error detection. When it detects an error, it tries to put 
the  data  back  to  how  it  should  have  been.  The  codes  which  are  used  for  both  error 
detection  and  error  correction  are  called  error  correction  codes.  The  error  correction 
techniques  are  of  three  types.  They  are  (1)  single  bit  error,  (2)  multiple  bit  error,  and  (3) 
burst  error.  The  process  or  method  of  correcting  single  bit  error  is  called  single  bit  error 
correction.  The  change  in  one  bit  in  the  whole  data  sequence  is  single  bit  error.  The 
occurrence  of  single  bit  error  is  very  rare  in  serial  communication  system.  If  there  is  a 
change  in  two  or  more  bits  of  data  sequence  of  transmitter to receiver, it is called multiple 
bit  error.  This  type  of error occurs in both serial type and parallel type data communication 
networks.  The  method  of  detecting  and  correcting  burst  errors  in  the  data  sequence  is 
called  burst  error.  It  is  the  change  of  set  of  bits  in  data  sequence.  The  burst  error  is 
calculated from the first bit change to the last bit change. 
 

 
 

Error Detecting Codes 


In  a  digital  communication  system,  errors  are  transferred  from  one communication system 
to  another,  along  with  the  data.  If  these  errors  are  not  detected  and  corrected, data will be 
lost.  For  effective  communication,  data  should  be  transferred  with  high  accuracy.  This  can 
be achieved by first detecting the errors and then correcting them. 

 
  11 
 
   

Module 4B: Codes 


 
 
Error  detection  is  the  process  of  detecting  the  errors  that  are  present  in  the  data 
transmitted  from  transmitter  to  receiver  in  a  communication  system.  We  use  some 
redundancy  codes  to  detect  these  errors  by  adding  to  the  data  while  it  is  transmitted from 
the source (transmitter). These codes are called error detecting codes. 
 
Richard  Hamming  was one of the first to actually construct and implement error correcting 
codes.  He  did  this  out  of  frustration  with  Bell  Lab’s  mechanical  relay  computer’s  inability to 
deal  with  errors. He said, “Damn it, if the machine can detect an error, why can’t it locate the 
position  and  correct  it?”  His research included work in the areas of coding theory, numerical 
methods, statistics, and digital filtering. 
 

Types of Error Detection 


1. Parity Checking 
2. Cyclic Redundancy Check (CRC) 
3. Longitudinal Redundancy Check (LRC) 
4. Check Sum 
 
Parity Checking 
Parity  bit  means  nothing  but  an  additional  bit  added  to  the  data  at  the  transmitter  before 
transmitting  the  data.  Before  adding  the  parity  bit,  the  number  of  1’s  or  zeros  is  calculated 
in  the data. Based on this calculation of data, an extra bit is added to the actual information/ 
data.  The  addition  of  parity  bit  to  the  data  will  result  in  the  change  of  data  string  size.  This 
means  if  we  have  an  8-bit  data,  then after adding a parity bit to the data binary string, it will 
become  a  9-bit  binary  data  string.  Parity  check  is  also  called  “Vertical  Redundancy  Check 
(VRC).” 
 
1. Even Parity 
● If the data has an even number of 1’s, the parity bit is 0. 
Example: 

10000001  111011001 

1100001100  1100000 

 
  12 
 
   

Module 4B: Codes 


 
 
 
● If the data has an odd number of 1’s, the parity bit is 1. 
Example: 

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 
 
   

Module 4B: Codes 


 
 
 
Longitudinal Redundancy Check 
In longitudinal redundancy method, a block of bits is arranged in a table format (in rows and 
columns),  and  we  will  calculate  the  parity  bit  for  each  column  separately.  The  set  of  these 
parity  bits  is  also  sent  along  with  our  original  data  bits.  Longitudinal  redundancy  check  is a 
bit by bit parity computation, as we calculate the parity of each column individually. 
 
This  method  can  easily  detect burst errors and single bit errors but it fails to detect the 2-bit 
errors occurring in the same vertical slice. 
 

 
 
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 
 
   

Module 4B: Codes 


 
 
Like  the  other  error  correction  codes,  Hamming  code  makes  use  of  the  concept  of  parity 
bits,  which  are  bits  that are added to the data, that the validity of data can be checked when 
it  is  read  or  after  it  has  been  received  in  data  transmission.  Using more than one parity bit, 
an  error  correction  code  can  not  only  identify  a  single  bit  error  in  the  data  unit, but also its 
location  in  the  data  unit.  In  a  digital  communication  system,  the  data  transfer  should  be 
error-free  and  with  high  accuracy.  The  data  errors  often  result  in  the  loss  of  important  or 
secure  data.  When  bits  are  transmitted  over  the  computer  network,  they  are  subject  to 
corruption  due  to  interference  and  network  problems.  The  corrupted  bits  lead  to  spurious 
data being received by the receiver and are called errors. 
 
Redundant  bits  are  extra  binary  bits  that  are  generated  and  added  to  the 
information-carrying  bits  of  data  transfer  to  ensure  that  no  bits  were  lost  during  the  data 
transfer. 
 
As  we  learned  earlier,  the  number  of  parity  bits  to  be  added  to a data string depends upon 
the  number  of  information  bits of a data string which is to be transmitted. Number of parity 
bits will be calculated by using the data bits. This relation is given below. 
 

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 
 
   

Module 4B: Codes 


 
 
Constructing a Bit Location Table 
In  Hamming  code,  each  parity  bit  checks  and  helps  in  finding  the  errors  in  the  whole 
codeword.  So  we  must  find  the  value  of  the  parity  bits  to  assign  them  a  bit  value.  By 
calculating  and  inserting  the  parity  bits  into  the  data  bits,  we  can  achieve  error  correction 
through Hamming code. 
 
Example: Encode the data 1101 in even parity by using Hamming code. 
 
Step 1. Calculate the required number of parity bits. 
Let P = 2 , then 
2P = 22 = 4 and n + P + 1 = 4 + 2 + 1 = 7 . 
 
Two parity bits are not sufficient for 4-bit data. 
So let’s try P = 3 . Then 
2P = 23 = 8 and n + P + 1 = 4 + 3 + 1 = 8 . 
 
Therefore, three parity bits are sufficient for 4-bit data. 
The total bits in the codeword is 4 + 3 = 7 . 
 
Step 2. Constructing bit location table. 
 
D7  D6  D5  P4  D3  P2  P1 
Bit Designation 
7  6  5  4  3  2  1 
Bit Location 
111  110  101  100  011  010  001 
Binary Location Number 

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 
 
   

Module 4B: Codes 


 
 
 
By entering/ inserting the parity bits at their respective positions, codewords can be formed 
and transmitted. It is 1100101. 
 

Formation 
 

Activity 1: Decipher Me!   30 minutes 


 

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 
 
   

Module 4B: Codes 


 
 
 
Guide Question 
The ASCII code for a blank space in the binary number is 0010 00002 . Why do you think it 
is important to have a code for a blank space? 
 

 
 
 
 
 

Activity 2: Convert Me!   30 minutes 


 

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 
 
   

Module 4B: Codes 


 
 
B. Find the difference. 
1. 9 ­ 6  in binary form 
2. 1010112 and 1001012  
3. 110010 and 010011

C. Find the product. 


1. 6×7  
2. 5×10 in binary form 
3. 11012 and 1102

D. Find the quotient. 


1. 21÷7  
2. 9
3 in binary form 
3. 110112 and 10012  
 
Guide Questions 
1. How  did  you  do  the  conversion  of  binary  numbers  to  decimal  numbers  and  vice 
versa? 
 

 
 
 
2. How  can  mathematics be a tool to explain the nature of binary numbers in computer 
systems? 
 

 
 
 
 
 
 
 
 
 
  19 
 
   

Module 4B: Codes 


 
 
 

Activity 3: Bit Me!   20 minutes 


 

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. 
 

Data  Even Parity Bit 

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   

Data  Odd Parity Bit 

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 
 
   

Module 4B: Codes 


 
 
II. Encode the following data in even parity by using the Hamming code. 
1. 1011 - 
2. 1010 - 
3. 0110 - 
4. 1110 - 
5. 0010 - 
 
Guide Questions 
Based on what are shown in the videos: 

1. What is your observation from the above table? 


 

 
 
 
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 
 
   

Module 4B: Codes 


 
 
In  digital  communication  systems,  errors  are  transferred  from  one  communication  system 
to  another  along  with  the  data,  it  is  from  the  transmitter  to  the  receiver.  If these errors are 
not  detected  and  corrected  during transmission, the data will be lost caused by the external 
noise  or  some  imperfections.  For  the  data  to  be  transferred  with  a  good  standard  of 
accuracy,  it could be achieved by first detecting the occurrence of errors and then correcting 
them.  Today,  technology  uses  error  detecting  codes  and  error  correction  to  have  an 
effective  communication.  Error  detection  involves  checking  whether  any error has occurred 
or  not.  Error  correction  involves  ascertaining  the  exact  number  of  bits  that  has  been 
corrupted and the location of the corrupted bits. 
 
 

  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 
 
   

Module 4B: Codes 


 
 
 
5. Which of the following is the special keyboard shortcut for “previous layout”? 
a. Ctrl F4 
b. Ctrl F7 
c. Ctrl F10 
d. Ctrl F12 
 

  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 
 
   

Module 4B: Codes 


 
 

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 
 
   

Module 4B: Codes 


 
 

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 
 

You might also like