You are on page 1of 69

STM10142 Discrete

Mathematics Topic 1 -
Numbering System
Topic 1 : Numbering System
1.1 Concept of numbering system
1.2 Decimal and binary numbering system
1.3 Octal numbering system

2
1.
Concept of Numbering
System

3
What is NUMBER SYSTEM
● A way to represent / writing numbers
● A mathematical notation - representing numbers of a
given set
● Use of digits or other symbols in a consistent manner
Source : Wikipedia

4
NUMBER SYSTEMS in computer
● Technique to represent numbers in the computer system
architecture
● Every value (letters or words) save into or get from computer
memory has a defined number system
● Computer translates them in numbers as computers can
understand only numbers
Source :tutorialspoint and includehelp.com

5
Types of NUMBER SYSTEMS
● Binary Number System
● Octal Number System
● Decimal Number System
● Hexadecimal (hex) number system

6
Binary Octal
NUMBER SYSTEMS NUMBER SYSTEMS
● Has only 2 digits ● Has only 8 digits
(0 and 1) (from 0 to 7)
● Also called as base-2 ● Also called base-8
● Every value represents ● Every value represents with
with o and 1 in this 0, 1, 2, 3, 4, 5, 6 and 7 in this
number system number system

7
Decimal Hexadecimal
NUMBER SYSTEMS NUMBER SYSTEMS
● Has only 10 digits ● Has only 16 alphanumeric
(from 0 to 9) values (from 0 to 9 and A to
● Also called base-10 F)
● Every value represents with ● Also called base-16
0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 ● Every value represents with 0,
in this number system 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C,
D, E and F in this number
system 8
Summary Table of the NUMBER
SYSTEMS
Number System Base Used Digits
Binary 2 0, 1
Octal 8 0, 1, 2, 3, 4, 5, 6, 7
Decimal 10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Hexadecimal 16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E,
F

9
1.1
Decimal number system
DECIMAL NUMBER SYSTEM
● Having 10 digit from 0 to 9
● A positional value system - the value of digits will depend on its
position
● Example :
○ In 731, value of 7 is 7 hundred or 700 or 7 x 100 or 7 x 10²
○ In 273, value of 7 is 7 tens or 70 or 7 x 10 or 7 x 101
● Digit value = digit x positional value
● The weightage of position can be represented as follows
104 103 102 101 100

103 102 101 100 . 10-1 10-2

11
Source : tutorialspoint
DECIMAL NUMBER SYSTEM (cont)
● Example 1 :
○ Decimal number : 12310 is made up of

(1 x 100) + (2 x 10) + (3 x 1)
(1 x 102) + (2 x 101) + (3 x 100)
100 + 20 + 3
123

Source : tutorialspoint
12
DECIMAL NUMBER SYSTEM (cont)
● Example 2 :
○ Decimal number : 456710 is made up of

(4 x 1000) + (5 x 100) + (6 x 10) + (7 x 1)


(4 x 103) + (5 x 102) + (6 x 101) + (7 x 100)
4000 + 500 + 60 + 7
4567

Source : tutorialspoint
13
DECIMAL NUMBER SYSTEM (cont)
● Example 3 :
○ Decimal number : 78.9110 is made up of

(7 x 10) + (8 x 1) + (9 x 0.1) + (1 x 0.01) +


(7 x 101) + (8 x 100) + (9 x 10-1) + (1 x 10-2)
70 + 8 + 0.9 + 0.01
78.91

Source : tutorialspoint
14
DECIMAL NUMBER SYSTEM
(Exercise 1)
Represent each of the following with its positional value

1) 2610
2) 89110
3) 785610
4) 6854210
5) 225.9810
6) 45.69110
15
DECIMAL NUMBER SYSTEM
(Exercise 2)
What is the positional value of digit 9 in each of the following.

1) 593110
2) 6329410
3) 225.9810
4) 45.69110

16
1.2
Binary number system
BINARY NUMBER SYSTEM
● Having 2 digit from 0 and 1
● Each binary digit is also call bit
● Number system used in computers
● A positional value system - each digit has a value expressed in
power of 2
24 = 16 23 = 8 22 = 4 21 = 2 20 = 1

● The rightmost digit is called Least Significant Bit (LSB) and


leftmost digit is called Most Significant Bit (MSB) :
1 0 0 0 1

MSB LSB
18
Source : tutorialspoint
BINARY NUMBER SYSTEM (cont)
Decimal Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
19
BINARY NUMBER SYSTEM (cont)
● Example :
○ Binary number : 12 can be represented as 1 x 20
○ Binary number : 102 can be represented as 1 x 21 + 0 x 20
○ Binary number : 1002 can be represented as 1 x 22 + 1 x
21 + 0 x 2 0

20
2.
Simplify Decimal and
Binary Numbering
System

21
2.1
Decimal to Binary
Conversion
DECIMAL TO BINARY CONVERSION
(Method 1 - Divide by 2 with Remainder)
● Step by step to convert number in decimal (base-10) to
binary (base-2)
○ Divide the number by 2, keeping notice the quotient and
remainder
○ Take the quotient, and keep dividing by 2 until the reach
zero (0)
○ Write out the remainder in reverse order (starting from
the Least Significant Bit (LSB) to Most Significant Bit
(MSB))
23
Source : wikihow.com
DECIMAL TO BINARY CONVERSION (Method
2 - Descending Power of 2 and Subtraction)

● Step by step to convert number in decimal (base-10) to binary


(base-2)
○ Start making a chart (power of 2 in base-2 table
○ Look the greatest power of 2 (biggest number that fit into
the decimal number)
○ Subtract decimal number with the power of 2 number
○ Write 1 under the beneath box in chart
○ Move to the next lower power of 2
○ Repeat this method until reach the end of chart

24
Source : wikihow.com
DECIMAL TO BINARY CONVERSION
(cont)
● Example 1
○ Convert decimal number 510 into binary number
Method 1 : Divide by Two (2) with Remainder
2 5 5 / 2 = 2 remainder 1
2 2 remainder 1 2 / 2 = 1 remainder 0
2 1 remainder 0 1 / 2 = 0 remainder 1
0 remainder 1

510 = 510 =
1012 1012 25
DECIMAL TO BINARY CONVERSION
(cont)
● Example 2
○ Convert decimal number 2410 into binary number
Method 2 : Descending Powers of Two (2) and Subtraction
23 22 21 20

8 4 2 1

1 0 1
5-4=1 1-1
=0
510 =
26
DECIMAL TO BINARY CONVERSION
(cont)
● Example 2
○ Convert decimal number 2410 into binary number
Method 1 : Divide by Two (2) with Remainder
2 24 24 / 2 = 12 remainder 0
2 12 remainder 0 12 / 2 = 6 remainder 0
2 6 remainder 0 6 /2 = 3 remainder 0
2 3 remainder 0 3 /2 = 1 remainder 1
2 1 remainder 1 1 /2 = 0 remainder 1
0 remainder 1
2410 = 110002
2410 = 110002 27
DECIMAL TO BINARY CONVERSION
(cont)
● Example 1
○ Convert decimal number 2410 into binary number
Method 2 : Descending Powers of Two (2) and Subtraction
25 24 23 22 21 20

32 16 8 4 2 1

1 1 0 0 0
24 - 16 = 8 16 - 8 = 0

2410 = 110002
28
DECIMAL TO BINARY CONVERSION
(Exercise 3)
Convert the following decimal numbers to their binary equivalents

1) 6410
2) 10110
3) 12810
4) 14710
5) 22510

29
2.2
Binary to Decimal
Conversion
BINARY TO DECIMAL CONVERSION
(Method 1 - Use Positional Notation)
● Step by step to convert number in binary (base-2) to decimal
(base-10)
○ Write down the binary number and list the powers of 2
from right to left
○ Write the digits of the binary number below their
corresponding power of 2
○ Write the final value of each power of 2
○ Add the final values

31
Source : wikihow.com
BINARY TO DECIMAL CONVERSION
(Method 2 - Use Doubling)
● Step by step to convert number in binary (base-2) to decimal
(base-10)
○ Write down the binary number
○ Starting from left, double previous total and add the current
digit
○ Double current digit and add the next leftmost digit
○ Repeat the previous step until out of digits

32
Source : wikihow.com
BINARY TO DECIMAL CONVERSION
(cont)
● Example 1
○ Convert binary number 101110 into decimal number
Method 1 : Use Positional Notation
23 22 21 20

8 4 2 1

1 0 1 1

8 + 0 2 1
+ + = 11

10112 =
33
BINARY TO DECIMAL CONVERSION
(cont)
● Example 2
○ Convert binary number 10112 into decimal number
Method 2 : Use Doubling
10112
0x2+1=1
1x2+0=2 10112 =
2x2+1=5 1110
5 x 2 + 1 = 11 34
BINARY TO DECIMAL CONVERSION
(cont)
● Example 1
○ Convert binary number 101101110 into decimal number
Method 1 : Use Positional Notation

26 25 24 23 22 21 20
64 32 16 8 4 2 1
1 0 1 1 0 1 1

64 0 16 8 0 2 1
+ + + + + + = 91

10110112 = 35
BINARY TO DECIMAL CONVERSION
(cont)
● Example 2
○ Convert binary number 10110112 into decimal number
Method 2 : Use Doubling
10110112
0x2+1=1
1x2+0=2
2x2+1=5 10110112 =
5 x 2 + 1 = 11
11 x 2 + 0 = 22 9110
22 x 2 + 1 = 45
45 x 2 + 1 = 91 36
DECIMAL TO BINARY CONVERSION
(Exercise 4)
Convert the following decimal numbers to their binary equivalents

1) 1012
2) 10102
3) 111012
4) 1011102
5) 11000012

37
3.
Octal Numbering
System

38
3.1
Octal number system
OCTAL NUMBER SYSTEM
● Have 8 possible digit value from 0 and 7
● Requires only 3 bits to represent value
● A positional value system - each digit has a value expressed in
power of 8
84 = 4096 83 = 512 82 = 64 81 = 8 80 = 1

● The rightmost digit is called Least Significant Bit (LSB) and


leftmost digit is called Most Significant Bit (MSB) :
2 5 1

MSB LSB

40
Source : tutorialspoint
OCTAL NUMBER SYSTEM (cont)
Decimal Octal Binary
0 0 000
1 1 001
2 2 010
3 3 011
4 4 100
5 5 101
6 6 110
7 7 111
8 10 1000
9 11 1001

41
OCTAL NUMBER SYSTEM (cont)
● Example :
○ Octal number : 18 can be represented as 1 x 80
○ Octal number : 108 can be represented as 1 x 81 + 0 x 80
○ Octal number : 2578 can be represented as 2 x 82 + 5 x 81
+ 5 x 80

42
3.1
Decimal to Octal
Conversion
DECIMAL TO OCTAL CONVERSION
(Method 1 - Converting with Division)
● Step by step to convert number in decimal (base-10) to octal
(base-8)
○ Write the decimal number
○ List the power of 8
○ Divide the decimal number by the largest power of 8
○ Find the remainder
○ Divide the remainder by the next power of 8
○ Repeat until found the full answer

44
Source : wikihow.com
DECIMAL TO OCTAL CONVERSION
(Method 2 - Converting with Remainders)
● Step by step to convert number in decimal (base-10) to octal
(base-8)
○ Write the decimal number
○ Divide the decimal number by 8
○ Find the remainder
○ Divide the answer to division problem by 8. Set aside
the remainder
○ Divide by 8 again
○ Repeat until find the final digit
45
Source : wikihow.com
DECIMAL TO OCTAL CONVERSION
(cont)
● Example
○ Convert decimal number 9810 into octal number
Method 1 : Converting with Division
80 =1 98 / 64 = 1 remainder 34
81 =8 34 / 8 = 4 remainder 2
82 = 64
2/1 = 2 remainder 0
83 = 512 > 98

9810 = 1428
46
DECIMAL TO OCTAL CONVERSION
(cont)
● Example
○ Convert decimal number 9810 into octal number
Method 2 : Converting with Remainder
8 98
8 12 remainder 2
8 1 remainder 4
0 remainder 1

9810 = 1428
47
DECIMAL TO OCTAL CONVERSION
(Exercise 5)
Convert the following decimal numbers to their octal equivalents

1) 12710
2) 45610
3) 109810
4) 626010

48
3.2
Octal to Decimal
Conversion
OCTAL TO DECIMAL CONVERSION
(Method 1 - Use Positional Notation)
● Step by step to convert number in octal (base-8) to decimal
(base-10)
○ Write down the binary number and list the powers of 8
from right to left
○ Write the digits of the octal number below their
corresponding power of 8
○ Write the final value of each power of 8
○ Add the final values
50
OCTAL TO DECIMAL CONVERSION
(Method 2 - Use Doubling)
● Step by step to convert number in octal (base-8) to decimal
(base-10)
○ Write down the octal number
○ Starting from left, double previous total and add the current
digit
○ Double current digit and add the next leftmost digit
○ Repeat the previous step until out of digits

51
Source : wikihow.com
OCTAL TO DECIMAL CONVERSION
(cont)
● Example 1
○ Convert octal number 1678 into decimal number
Method 1 : Use Positional Notation
82 81 80

64 8 1
1 6 7

64 48 7
+ + = 119

1678 =
52
OCTAL TO DECIMAL CONVERSION
(cont)
● Example 1
○ Convert octal number 1678 into decimal number
Method 2 : Use Doubling

1678
0x8+1=1 1678 =
1 x 8 + 6 = 14 11910
14x 8 + 7 = 119

53
OCTAL TO DECIMAL CONVERSION
(cont)
● Example 2
○ Convert OCTAL number 14638 into decimal number
Method 1 : Use Positional Notation
83 82 81 80

512 64 8 1
1 4 6 3

512 256 48 3
+ + + = 819

14638 = 81910
54
OCTAL TO DECIMAL CONVERSION
(cont)
● Example 2
○ Convert octal number 14638 into decimal number
Method 2 : Use Doubling

14638
0x8+1=1
1 x 8 + 4 = 12 14638 = 81910
12 x 8 + 6 = 102
102 x 8 + 3 = 819
55
OCTAL TO DECIMAL CONVERSION
(Exercise 6)
Convert the following octal numbers to their decimal equivalents

1) 1258
2) 6748
3) 20618

56
4.
Binary and Octal
Number System

57
4.1
Binary to Octal
Conversion
BINARY TO OCTAL CONVERSION
(Method 1 - Converting by Hand)
● Step by step to convert number in binary (base-2) to octal (base-8)
○ Recognize series of binary numbers
○ Group the binary number in sets of 3, starting from right
○ Add zero to the left digit if don’t have enough digits to make set of
3
○ Add 4, 2 and 1 underneath each set of 3 numbers to note
placeholders
○ If there is a one above any placeholders, write the number (4, 2 or
1) to start octal number
○ Add up the new numbers on each set of 3
○ Place the newly converted answers together
59
Source : wikihow.com
BINARY TO OCTAL CONVERSION
(Method 2 - Converting Shortcuts)
● Step by step to convert number in binary (base-2) to octal
(base-8)
○ Use a simple octal conversion chart to save time and
work
○ Group the binary number in sets of 3, starting from right
○ Add zero to the left digit if don’t have enough digits to make
set of 3
○ Use the octal conversion chart to convert to each set of 3
binary numbers to octal numbers

60
Source : wikihow.com
BINARY TO OCTAL CONVERSION
(cont)
● Example 1
○ Convert binary number 110111012 into octal number
Method 1 : Converting by Hand
11011101

011 011 101


421 421 421

021 021 401 110111012 =


3 3 5 3358
335
61
BINARY TO OCTAL CONVERSION
(cont)
● Example 1
○ Convert binary number 110111012 into octal number
Method 2 : Converting Shortcuts
Octal Binary
11011101
0 000
1 001 011 011 101
2 010 3 3 5
3 011
335
4 100
5 101
6 110
7 111
110111012 =
62
335
BINARY TO OCTAL CONVERSION
(Exercise 7)
Convert the following binary numbers to their octal equivalents

63
4.2
Octal to Binary
Conversion
OCTAL TO BINARY CONVERSION
(Method 1 - Two Step Converting)
● Step by step to convert number in octal (base-8) to binary (base-2)
○ Convert octal number to decimal number (use any method given)
○ Get and write the decimal number
○ Convert the decimal number to binary number (use any method
given)
○ The binary number converted is the final answer

65
OCTAL TO BINARY CONVERSION
(Method 2 - Converting Shortcuts)
● Step by step to convert number in octal (base-8) to binary
(base-2)
○ Use a simple octal conversion chart to save time and
work
○ Use the octal conversion chart to convert to each digit of octal
number into set of 3 binary numbers

66
OCTAL TO BINARY CONVERSION
(cont)
● Example 1
○ Convert octal number 1258 into decimal number
Method 1 : Two Step Converting
82 81 80 85 / 2 = 42 remainder 1
42 / 2 = 21 remainder 0
64 8 1 21 / 2 = 10 remainder 1
1 2 5 10 / 2 = 5 remainder 0
5/2 = 2 remainder 1
64 16 5
+ + = 85 2/2 = 1 remainder 0
1/2 = 0 remainder 1
1258 = 8510 858 =
67
OCTAL TO BINARY CONVERSION
(cont)
● Example 1
○ Convert octal number 1258 into binary number
Method 2 : Converting Shortcuts
Octal Binary
125
0 000
1 001 1 2 5
2 010 001 010 101
3 011
335
4 100
5 101
6 110
7 111
1258 =
68
1010101
OCTAL TO BINARY CONVERSION
(Exercise 8)
Convert the following octal numbers to their binary equivalents

69

You might also like