Digital Logic Design
Number System
Engr. Sohaib Hafeez
Lecturer CS Dept
1
The Basics of Number System
What is Number System ?
A number system is a method to represent
numbers mathematically. It can use
arithmetic operations to represent every
number uniquely. To represent a number, it
requires a base or radix.
2
The Basics of Number System
Types of Number System
There are four common types of number systems
based on the radix or base of the number :
Decimal number system or Base 10 number
system
Binary number system or Base 2 number system
Octal number system or Base 8 number system
Hexadecimal number system or Base 16 number
system
3
The Basics of Number System
Number System Conversion Methods
A number N in base or radix b can be written
as:
(N)b = dn-1 dn-2 -- -- -- -- d1 d0 . d-1 d-2 -- -- -- -- d-m
In the above, dn-1 to d0 is the integer part, then follows a radix point, and
then d-1 to d-m is the fractional part.
dn-1 = Most significant bit (MSB)
d-m = Least significant bit (LSB)
4
The Basics of Number System
Number System Conversion
In this article, you will learn the conversion of one
base number to another base number considering
all the base numbers such as decimal, binary,
octal and hexadecimal with the help of examples.
Here, the following number system conversion
methods are explained.
5
The Basics of Number System
6
The Basics of Number System
Number System Conversion
1. Binary to Decimal Conversion
2. Binary to Octal Conversion
3. Binary to Hexadecimal Conversion
4. Decimal to Binary Conversion
5. Decimal to Octal Conversion
6. Decimal to Hexadecimal Conversion
7. Octal to Binary Conversion
8. Octal to Decimal Conversion
9. Octal to Hexadecimal Conversion
10. Hexadecimal to Binary Conversion
11. Hexadecimal to Decimal Conversion
12. Hexadecimal to Octal Conversion
7
The Basics of Number System
1. Binary to Decimal Conversion
The process of converting binary to decimal is quite
simple. The process starts from multiplying the bits of
binary number with its corresponding positional weights.
And lastly, we add all those products.
8
The Basics of Number System
1. Binary to Decimal Conversion
Example 1: (10110.001)2
We multiplied each bit of (10110.001)2 with its respective
positional weight, and last we add the products of all the
bits with its weight.
(10110.001)2=(1×24)+(0×23)+(1×22)+(1×21)+(0×20)+
(0×2-1)+(0×2-2)+(1×2-3)
(10110.001)2=(1×16)+(0×8)+(1×4)+(1×2)+(0×1)+
(0×1⁄2)+(0×1⁄4)+(1×1⁄8)
(10110.001)2=16+0+4+2+0+0+0+0.125
(10110.001)2=(22.125 )10
9
The Basics of Number System
2. Binary to Octal Conversion
The base numbers of binary and octal are 2 and 8,
respectively. In a binary number, the pair of three bits is
equal to one octal digit. There are only two steps to
convert a binary number into an octal number which are as
follows:
In the first step, we have to make the pairs of three bits on
both sides of the binary point. If there will be one or two
bits left in a pair of three bits pair, we add the required
number of zeros on extreme sides.
In the second step, we write the octal digits corresponding to
each pair.
10
The Basics of Number System
2. Binary to Octal Conversion
11
The Basics of Number System
2. Binary to Octal Conversion
Example 1: (111110101011.0011) 2
1. Firstly, we make pairs of three bits on both sides of the
binary point.
111 110 101 011.001 1
On the right side of the binary point, the last pair has only one bit.
To make it a complete pair of three bits, we added two zeros on
the extreme side.
111 110 101 011.001 100
2. Then, we wrote the octal digits, which correspond to each pair.
(111110101011.0011) =(7653.14)
2 8
12
The Basics of Number System
3. Binary to Hexadecimal Conversion
The base numbers of binary and hexadecimal are 2 and 16,
respectively. In a binary number, the pair of four bits is equal to
one hexadecimal digit. There are also only two steps to convert a
binary number into a hexadecimal number which are as follows:
In the first step, we have to make the pairs of four bits on both
sides of the binary point. If there will be one, two, or three bits left
in a pair of four bits pair, we add the required number of zeros on
extreme sides.
In the second step, we write the hexadecimal digits
corresponding to each pair
13
The Basics of Number System
2. Binary to Hex Conversion Table
14
The Basics of Number System
3. Binary to Hexadecimal Conversion
Example 1: (10110101011.0011)2
1. Firstly, we make pairs of four bits on both sides of the
binary point.
101 1010 1011.0011
On the left side of the binary point, the first pair has three bits. To make it a
complete pair of four bits, add one zero on the extreme side.
0101 1010 1011.0011
2. Then, we write the hexadecimal digits, which correspond to each pair.
(011110101011.0011) =(5AB.3)
2 16
15
The Basics of Number System
4. Decimal to Binary Conversion
For converting decimal to binary, there are two steps required to
perform, which are as follows:
In the first step, we perform the division operation on the
integer and the successive quotient with the base of binary(2).
Next, we perform the multiplication on the integer and the
successive quotient with the base of binary(2).
16
The Basics of Number System
4. Decimal to Binary Conversion
First Method
Example 1: (10.25)10
Note: Keep multiplying the fractional part with 2 until decimal part 0.00 is obtained.
(0.25)10 = (0.01)2
Answer: (10.25)10 = (1010.01)2
17
The Basics of Number System
4. Decimal to Binary Conversion
Second Method
Example 1: (152.25)10
Step 1: Operation Quotient Remainder
Divide the number 152 and
its successive quotients with
152/2 76 0 (LSB)
base 2.
(152)10=(10011000)2 76/2 38 0
38/2 19 0
19/ 9 1
9/2 4 1
4/2 2 0
2/2 1 0
1/2 0 1(MSB) 18
The Basics of Number System
4. Decimal to Binary Conversion
Example 1: (152.25)10
Step 2:
Now, perform the multiplication of 0.27 and successive fraction with base 2.
(0.25)10=(.01)2
(152.25)10 =(10011000.
Operation 01)2
Result carry
0.25×2 0.50 0
0.50×2 0 1
19
The Basics of Number System
5. Decimal to Octal Conversion
For converting decimal to octal, there are two steps required to
perform, which are as follows:
In the first step, we perform the division operation on the integer
and the successive quotient with the base of octal(8).
Next, we perform the multiplication on the integer and the
successive quotient with the base of octal(8).
20
The Basics of Number System
5. Decimal to Octal Conversion
Example 1: (152.25)10
Step 1:
Divide the number 152 and its successive quotients with base 8
Operation Quotient Remainder
152/8 19 0
19/8 2 3
2/8 (152)10=(230)08 2
21
The Basics of Number System
5. Decimal to Octal Conversion
Step 2:Now perform the multiplication of 0.25
and successive fraction with base 8.
Operation Result carry
0.25×8 0 2
(0.25)10=(2)8
So, the octal number of the decimal number
152.25 is 230.2
22
The Basics of Number System
6. Decimal to Hexadecimal conversion
For converting decimal to hexadecimal, there are two steps
required to perform, which are as follows:
In the first step, we perform the division operation on the integer
and the successive quotient with the base of hexadecimal (16).
Next, we perform the multiplication on the integer and the
successive quotient with the base of hexadecimal (16).
23
The Basics of Number System
6. Decimal to hexadecimal conversion
Example 1: (152.25)10
Step 1:Divide the number 152 and its successive quotients with base 16
Operation Quotient Remainder
152/16
(152) 9 8
10=(98)16
9/16
Step 2:Now perform0the multiplication of 0.25
9 and successive fraction
with base 16.
Operation Result carry
0.25×16 0 4 24
The Basics of Number System
6. Decimal to hexadecimal conversion
Example 1: (152.25)10
Step 2:Now perform the multiplication of 0.25 and successive fraction
with base 16.
Operation Result carry
0.25×16 0 4
(0.25)10=(4)16
So, the hexadecimal number of the decimal
number 152.25 is 230.4.
25
The Basics of Number System
7. Octal to Decimal Conversion
The process of converting octal to decimal is the same as binary to decimal. The process
starts from multiplying the digits of octal numbers with its corresponding positional weights.
And lastly, we add all those products.
Let's take an example to understand how the conversion is done from octal to decimal.
26
The Basics of Number System
7. Octal to Decimal Conversion
Example 1: (152.25)8
Step 1:We multiply each digit of 152.25 with its respective positional weight, and last we add the products of all the bits with its
weight.
(152.25)8=(1×82)+(5×81)+(2×80)+(2×8-1)+(5×8-2)
(152.25)8=64+40+2+(2×1⁄8)+(5×1⁄64)
(152.25)8=64+40+2+0.25+0.078125
(152.25)8=106.328125
So, the decimal number of the octal number 152.25 is 106.328125
27
The Basics of Number System
8. Octal to Binary Conversion
The process of converting octal to binary is the reverse process of binary to octal. We write the three
bits binary code of each octal number digit.
Example 1: (152.25)8
We write the three-bit binary digit for 1, 5, 2, and 5.
(152.25)8=(001101010.010101)2
So, the binary number of the octal number 152.25 is (001101010.010101)2
28
The Basics of Number System
9. Octal to Hexadecimal conversion
For converting octal to hexadecimal, there are two steps required to perform, which are as follows:
In the first step, we will find the binary equivalent of number 25.
Next, we have to make the pairs of four bits on both sides of the binary point. If there will be one,
two, or three bits left in a pair of four bits pair, we add the required number of zeros on extreme
sides and write the hexadecimal digits corresponding to each pair.
29
The Basics of Number System
9. Octal to hexadecimal conversion
Example 1: (152.25)8
Step 1:We write the three-bit binary digit for 1, 5, 2, and 5
(152.25)8=(001101010.010101)2
So, the binary number of the octal number 152.25 is (001101010.010101)2
30
The Basics of Number System
9. Octal to hexadecimal conversion
Example 1: (152.25)8
Step 2:
1. Now, we make pairs of four bits on both sides of the binary point.
0 0110 1010.0101 01
On the left side of the binary point, the first pair has only one digit, and on the right side, the last pair has only two-digit. To make them complete
pairs of four bits, add zeros on extreme sides.
0000 0110 1010.0101 0100
2. Now, we write the hexadecimal digits, which correspond to each pair.
(0000 0110 1010.0101 0100) 2=(6A.54)16
31
The Basics of Number System
10. Hexa-decimal to Decimal Conversion
The process of converting hexadecimal to decimal is the same as binary to decimal. The process starts from
multiplying the digits of hexadecimal numbers with its corresponding positional weights. And lastly, we add all
those products.
Let's take an example to understand how the conversion is done from hexadecimal to decimal.
32
The Basics of Number System
10. Hexa-decimal to Decimal Conversion
Example 1: (152A.25)
16
Step 1:We multiply each digit of 152A.25 with its respective positional weight, and last we add the products of all the bits with its weight.
(152A.25)16=(1×163)+(5×162)+(2×161)+(A×160)+(2×16-1)+(5×16-2)
(152A.25)16=(1×4096)+(5×256)+(2×16)+(10×1)+(2×16 -1)+(5×16-2)
(152A.25)16=4096+1280+32+10+(2×1⁄16)+(5×1⁄256)
(152A.25)16=5418+0.125+0.125
(152A.25)16=5418.14453125
So, the decimal number of the hexadecimal number 152A.25 is 5418.14453125
33
The Basics of Number System
10. Hexa-decimal to Decimal Conversion
Example 1: (152A.25)
16
Step 1:We multiply each digit of 152A.25 with its respective positional weight, and last we add the products of all the bits with its weight.
(152A.25)16=(1×163)+(5×162)+(2×161)+(A×160)+(2×16-1)+(5×16-2)
(152A.25)16=(1×4096)+(5×256)+(2×16)+(10×1)+(2×16 -1)+(5×16-2)
(152A.25)16=4096+1280+32+10+(2×1⁄16)+(5×1⁄256)
(152A.25)16=5418+0.125+0.125
(152A.25)16=5418.14453125
So, the decimal number of the hexadecimal number 152A.25 is 5418.14453125
34
The Basics of Number System
11. Hexadecimal to Binary Conversion
The process of converting hexadecimal to binary is the reverse process of binary to hexadecimal. We write the four bits binary
code of each hexadecimal number digit.
Example 1: (152A.25) We write the four-bit binary digit for 1, 5, A, 2, and 5.
16
(152A.25)16=(0001 0101 0010 1010.0010 0101)2
So, the binary number of the hexadecimal number 152.25 is (1010100101010.00100101)2
35
The Basics of Number System
12. Hexadecimal to Octal Conversion
For converting hexadecimal to octal, there are two steps required to perform, which are as follows:
In the first step, we will find the binary equivalent of the hexadecimal number.
Next, we have to make the pairs of three bits on both sides of the binary point. If there will be one or two bits left in a pair
of three bits pair, we add the required number of zeros on extreme sides and write the octal digits corresponding to each
pair.
36
The Basics of Number System
12. Hexadecimal to Octal Conversion
Example 1: (152A.25)
16
Step 1:We write the four-bit binary digit for 1, 5, 2, A, and 5.
(152A.25)16=(0001 0101 0010 1010.0010 0101)2
So, the binary number of hexadecimal number 152A.25 is (0011010101010.010101)2
Step 2: Then, we make pairs of three bits on both sides of the binary point.
001 010 100 101 010.001 001 010
Then, we write the octal digit, which corresponds to each pair.
(001010100101010.001001010)2=(12452.112)8
So, the octal number of the hexadecimal number 152A.25 is 12452.112
37
The Basics of Number System
12. Hexadecimal to Octal Conversion
Example 1: (152A.25)
16
Step 1:We write the four-bit binary digit for 1, 5, 2, A, and 5.
(152A.25)16=(0001 0101 0010 1010.0010 0101)2
So, the binary number of hexadecimal number 152A.25 is (0011010101010.010101)2
Step 2: Then, we make pairs of three bits on both sides of the binary point.
001 010 100 101 010.001 001 010
Then, we write the octal digit, which corresponds to each pair.
(001010100101010.001001010)2=(12452.112)8
So, the octal number of the hexadecimal number 152A.25 is 12452.112
38