MODULE 6 - Codes
MODULE 6 - Codes
6 CODES
https://tinyurl.com/y2v3dckn
Overview
Learning Outcomes
b. Exemplify honesty and integrity when using codes for security purposes (V)
Page 116
GEED10053_Mathematics In The Modern World_JKFS
Course Materials
Coding Scheme is a convention that associates each character with character set
with a unique bit pattern-a binary representation of the integers from 0. (Tabut, 2015)
American Standard Code for Information Interchange is the most common format for
text file in computers and on the internet. In an ASCII file, each alphabetic, numeric, or
special character in representation with a 7-bit binary number (as string of seven 0’s or 1’s)
EBCDIC (Extended Binary Coded Decimal Interchange Code)
Extended Binary Coded Decimal Interchange Code is a binary code for alphabetic,
numeric characters that IBM developed for its largest systems. IBM (Internet Business
Machines) is the largest computer company in the world. IBM started in 1911 as a producer
of punch card tabulating machines. IBM came to donate the new field of mainframe and
minicomputers.
✓ It has 8-bit, 4-bits for zone, 4-bits for digits.
✓ It allows 28 = 256 combinations and represents 256 unique symbols.
✓ It is used mainly in mainframe computers.
Universal code is the coding scheme that is new ANSI (American National Standard
Institute) standards. It supports most of the world’s languages and is becoming the Internet
standard. It is a 16-bit coding scheme that has the capacity of representing more than 65,000
characters and symbols.
✓ It represents text, symbols, characters in multilingual environment.
✓ It uniquely represents a symbol in language like China and Japanese, etc. and
mathematical and scientific symbols.
✓ It has 32 bits and allows 232 approximately 4 billion combinations.
✓ It is compatible and identical to ASCII-8.
✓ It is implemented by character encoding and commonly used encoding scheme. It
uses 8-32 bits per code.
Page 117
GEED10053_Mathematics In The Modern World_JKFS
Lesson 1: Binary codes
Watch: How exactly does binary code work? - José Américo N L F de Freitas
(https://www.youtube.com/watch?v=wgbV6DLVezo)
A 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. For example, a binary string of eight bits can represent any of 256
possible values and can, therefore, represent a wide variety of different items. (Wikipedia)
Binary file
Binary file is a type of computer file that is used to store binary data. It may contain any type
of formatted or unformatted data encoded within binary format.
An integer is a datum of integral data type, a data type that represents some range of
mathematical integers. Integers are commonly represented in a computer as a group of binary
digits (bits).
Byte initially meant (the smallest addressable unit of memory”. In the past, 5-,6-,7-,8-, and 9-
bit bytes all been used.
Octet always refers to an 8-bit quantity. It is mostly used in the field of computer networking,
where computers with different byte widths might have to communicate.
“Word” is used for a small group of bits that are handled simultaneously by processors of a
particular architecture.
Short integer can represent a whole number that may take less storage, while having a smaller
range, compared with a standard integer on the same machine.
Long integer can represent a whole integer whose range is greater than or equal to that of a
standard integer on the same machine.
Computer system regularly use numeral system of bases other than 10.
✓ Base 2 (binary)
✓ Base 8 (octal)
✓ Base 16 (hexadecimal) numeral systems
Are used because designing a computer system is simpler in this manner than for other
bases. Binary numbers are the core of all computer operations
Page 118
GEED10053_Mathematics In The Modern World_JKFS
Operations on Binary Numbers
Decimal
Let us have this example 329 for the base 10 or decimal
The binary addition operation works similarly to the base 10 decimal system, except
that it is a base 2 system. The binary system consists of only two digits, 1 and 0. Most of the
functionalities of the computer system use the binary number system. The binary code uses
the digits 1’s and 0’s to make certain processes turn off or on. The process of the addition
operation is very familiar to the decimal system by adjusting to the base 2.
Before attempting the binary addition process, we should have complete knowledge of
how the place works in the binary number system. Because most of the modern digital
computers and electronic circuits perform the binary operation by representing each bit as a
voltage signal. The bit 0 represents the “OFF” state, and the bit 1 represents the “ON” state.
To add binary numbers, let us remember the following “Magic Table”
0+0=0
1+0=1
0+1=1
1 + 1 = 10
1 + 1 + 1 = 11
Page 119
GEED10053_Mathematics In The Modern World_JKFS
A few examples of binary additions are as follows:
Example 1: 10001 + 11101 Example 2: 10111 + 110001
Solution: Solution:
1 111
10001 10111
(+) 1 1 1 0 1 (+) 1 1 0 0 0 1
———————– ———————–
101110 1001000
Binary subtraction is one of the four binary operations, where we perform the
subtraction method for two binary numbers (comprising of only two digits, 0 and 1). This
operation is similar to the basic arithmetic subtraction performed on decimal numbers in Maths.
Hence, when we subtract 1 from 0, we need to borrow 1 from the next higher order digit, to
reduce the digit by 1 and the remainder left here is also 1.
Can you subtract binary numbers? The answer is yes. Subtraction of binary numbers
is an arithmetic operation similar to the subtraction of decimal numbers or base 10 numbers.
For example, 1 + 1 + 1 = 3 in base 10 and 1 + 1 + 1 = 11 in binary number system. When you
add and subtract binary numbers, you will need to be careful when borrowing as these will take
place more often.
When you subtract several columns of binary digits, you must take into account the
borrowing. When 1 is to be subtracted from 0, the result is 1 where 1 is borrowed from the next
highest order bit or digit.
0–0=0
1–0=1
1–1=0
0 – 1 = 1 (Borrow 1)
Page 120
GEED10053_Mathematics In The Modern World_JKFS
Consider other examples of binary subtractions are as follows:
1: 0011010 – 001100
Solution:
1 1 Borrow
0011010
(-) 0 0 1 1 0 0
——————
0001110
Decimal Equivalent:
0 0 1 1 0 1 0 = 26
0 0 1 1 0 0 = 12
Therefore, 26 – 12 = 14
The binary resultant 0 0 0 1 1 1 0 is equivalent to the
14
2: 0100010 – 0001010
Solution:
1 1 Borrow
0 1 0 0 0 1 0 = 3410
(-) 0 0 0 1 0 1 0 = 1010
—————
0 0 1 1 0 0 0 = 2410
Similar to the decimal system, the multiplication of the binary numbers is done by
multiplying the multiplicand with the multiplier. It is noted that the multiplication by zero makes
all the bits zero, and this step may be ignored in the intermediate steps. The multiplication by
1 makes all the multiplicand value unchanged.
0×0=0
0×1=0
1×0=0
1×1=1
Page 121
GEED10053_Mathematics In The Modern World_JKFS
Some binary multiplication examples are given below for a better understanding of this
concept.
1: Solve 1010 × 101
Solution:
1010 × 101
1010
(×) 101
—————–
1010
0000
——————
01010 ……. First Intermediate
Sum
1010
——————–
110010
Page 122
GEED10053_Mathematics In The Modern World_JKFS
Watch: Dividing Binary Numbers (https://www.youtube.com/watch?v=ubCCemtuZH8)
The binary division operation is similar to the base 10 decimal system, except the base
2 system. The division is probably one of the most challenging operations of the basic
arithmetic operations. There are different ways to solve division problems using binary
operations. Long division is one of them and the easiest and the most efficient way.
The binary division is much easier than the decimal division when you remember the
following division rules. The three main rules of the binary division include:
1÷1 = 1
1÷0 = 0
0÷1 = Meaningless
0÷0 = Meaningless
Similar to the decimal number system, the binary division is similar, which follows the four-
step process
Divide
Multiply
Subtract
Bring down
Important Note: Binary division follows the long division method to find the resultant in an
easy way. In dividing binary numbers, we will use the same process as in decimals
Some binary division examples are given below for a better understanding of this concept.
Solution:
Given
01111100 ÷ 0010
Remove the zero’s in the Most Significant Bit in both the dividend and divisor, that
doesn’t change the value of the number.
Page 123
GEED10053_Mathematics In The Modern World_JKFS
Now, use the long division method.
Step 1: First, look at the first two numbers in the dividend and compare with the divisor. Add
the number 1 in the quotient place. Then subtract the value, you get 1 as remainder.
Step 2: Then bring down the next number from the dividend portion and do the step 1 process
again
Step 3: Repeat the process until the remainder becomes zero by comparing the dividend and
the divisor value.
Step 4: Now, in this case, after you get the remainder value as 0, you have zero left in the
dividend portion, so bring that zero to the quotient portion.
So, when you bring down the fourth bit of the dividend, it does not match with the
divisor. In order to bring down the 5th and 6th bit of the dividend, add two zeros in the quotient
value.
Page 124
GEED10053_Mathematics In The Modern World_JKFS
Lesson 3: Text data
Text Data (techopedia) mining involves combing through a text document or resource to get
valuable structured information. This requires sophisticated analytical tools that process text
in order to glean specific keywords or key data points from what are considered relatively raw
or unstructured formats. Text data mining is also known as text mining or text analytics.
Sentiment analysis is a unique component of text mining which is generally much more
difficult than statistical analysis.
It ensures that corrected and error-free messages are obtained at the receiver side.
ARQ is an error control (error control) method that uses error-detection codes and positive
and negative acknowledgements.
In networking, Error Detection refers to the techniques used to detect noise or other
impairments introduced into data while it is transmitted from source to destination.
Parity is the oldest method of error correction. It works by adding an additional bit to each
character word transmitted. The state of the bit is determined by a number of factors such as
the type of parity and the number of logic-one bits in the data character.
Parity Bit is a bit appended to the data of binary bits to ensure that the total number of 1’s in
the data are even or odd. Parity bits are used for error detection.
Page 125
GEED10053_Mathematics In The Modern World_JKFS
Two types of Parity Bits
1. Even Parity
In the case of even parity, for a given set of bits, the number of 1’s are counted. If that
count is odd, the parity bit value is set to 1, making the total count of occurrences of 1’s an
even number. If the total number of 1’s in a given set of bits is already even, the parity
bit’s value is 0.
Another mechanism that relates to error detection. It is a coding schema that repeats bits
across channels to achieve error-free communication.
However, they are simple and used in the transmission of number stations.
Checksum
Is an error detection method that is a modular arithmetic sum of message code words of
fixed word length. Checksum schemes involve longitudinal redundancy checks, parity bits
and check digits.
Hamming Codes is a set of error-correction codes that can be used to detect and correct the
errors that can occur when the data is moved or stored from the sender to the receiver. It is
technique developed by R.W. Hamming for error correction.
It can be applied to data units of any length. It is used to detect and correct single bit error.
If the receiver did not get the correct message, there must be an error in the message.
We can use Hamming code to detect and correct the error.
Page 126
GEED10053_Mathematics In The Modern World_JKFS
Rules:
The value of parity (P) bits are determined by the sequence of bits that is alternatively as
checks and skips.
Given that Hamming code is used to detect error in transmitting code and correct the error in
the transmitted code. Parity bits indicate if a binary number has odd or even number of 1’s
Solution:
1001 –even parity because it has two 1’s
1110 – odd parity because it has three 1’s
The transmitted code (received code) has two parts the message bits and the parity bits. If
the original message is 1001 and received as 11001, then the message bits are 1001 and
the parity bit is 1 in the first place from the left.
Redundant bits
Extra 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.
The number of redundant bits can be calculated using the following formula:
2p >m + p + 1,
where, p = redundant/parity bit, m = data/message bit
Example
Suppose the number of data bits is 7, then the number of redundant bits can be calculated
using:
24 >7 + 4 + 1 → 16 >12
Thus, the number of redundant bits = 4 bits greater than 12.
Repetition
Repetition of codes happens because sometimes one code may be repeated for every
data bit in multiple times and can be checked if it was sent correctly. For instance, if the data
bit to be sent is a 1, an n = 3 repetition code will send 111. If the three bits received are not
identical, an error occurred during transmission. If the channel is clean enough, most of the
time only one bit will change in each triple. Therefore, 001, 010, and 100 each correspond to
a 0 bit, while 110, 101, and 011 correspond to a 1 bit, with the greater quantity of digits that
are the same (0 or a 1) indicating what the data bit should be. A code with this ability to
reconstruct the original message in the presence of errors is known as an error-correcting
code. This triple repetition code is Hamming code with m = 2, since there are two parity bits,
and 22-2 – 1 = 1 data bit.
Page 127
GEED10053_Mathematics In The Modern World_JKFS
Assessment
1. 1010 + 1010
2. 11101 + 1010
3. 11111 + 11111
4. 1001 – 11
5. 1101 – 11
6. 10001 – 100
7. 101 * 10
8. 1011 * 101
9. 1101/11
10. 10111/10
II. Test if these code words are correct, assuming they were created using an even parity
Hamming Code. If one is incorrect, indicate what the correct code word should have been.
Also, indicate what the original data was.
1. 010101100011
2. 111110001100
3. 000010001010
Grading System
Numerical Scores
Page 128
GEED10053_Mathematics In The Modern World_JKFS
References
Online
Freitas L. TED-Ed (2018, July 12) How exactly does binary code work?
https://www.youtube.com/watch?v=wgbV6DLVezo
Binary Addition-Definition, Rules, Method, Tricks and Examples
https://byjus.com/maths/binary-addition/
Binary Subtraction(Rules, Examples, 1/s complement)
https://byjus.com/maths/binary-subtraction/
Binary Multiplication (Rules and Solved Examples)
https://byjus.com/maths/binary-multiplication/
Binary Division-Rules, Tricks, Examples and Steps to Solve Questions
https://byjus.com/maths/binary-division/
BitMerge (2018,January 28) Unicode
https://www.youtube.com/watch?v=2r6OZD5n-wc
Neso Academy (2015, January 20) Hamming Code l Error detection
https://www.youtube.com/watch?v=1A_NcXxdoCc
Neso Academy (2015, January 20) Hamming Code l Error correction
https://www.youtube.com/watch?v=wbH2VxzmoZk
Neso Academy (2014, October 17) What is Parity?
https://www.youtube.com/watch?v=DdMcAUlxh1M
Raut, N. (2019, January 2) Hamming code for single error correction, double detection
https://www.tutorialspoint.com/hamming-code-for-single-error-correction-double-error-
detection
The Organic Chemistry Tutor (2018, May 26.) How to Add Binary Numbers
https://www.youtube.com/watch?v=5F6orbqZigI
The Organic Chemistry Tutor (2019, November 3) ASCII Code and Binary
Page 129
GEED10053_Mathematics In The Modern World_JKFS
https://www.youtube.com/watch?v=H4l42nbYmrU
The Organic Chemistry Tutor (2018, May 26). How to Subtract Binary Numbers
https://www.youtube.com/watch?v=OHf0Eg9ZhGQ
The Organic Chemistry Tutor (2018, May 26). Dividing Binary Numbers
https://www.youtube.com/watch?v=ubCCemtuZH8
The Organic Chemistry Tutor (2018, May 26). Multiplying Binary Numbers
https://www.youtube.com/watch?v=Va_UvwJULcI
The Tech Train (2017, Decemebr 6) Understanding ASCII and UNICODE (GCSE)
https://www.youtube.com/watch?v=5aJKKgSEUnY
Wikipedia (2020, September 8) Binary Codehttps://en.wikipedia.org/wiki/Binary_code
Page 130
GEED10053_Mathematics In The Modern World_JKFS