Lecture 1 (NumberBaseConversion)
Lecture 1 (NumberBaseConversion)
CP 120
DR. MAY ALASHWAL
Major objective of this course is to familiarize the
students with the knowledge and understanding
of Boolean algebra and digital concepts, with
Objectives of concentration on the analysis and design of
This Course combinational and sequential logic circuits.
Furthermore, it provides a foundation for
subsequent study in computer architecture,
Computer organization and Assembly.
2
Expected Results
On successful completion of this course, students
will be able to:
3
CP 120 – Digital Logic
Design
Course syllabus in Moodle
4
Textbook
Introduction to Logic Design (3rd Edition) by
Alan B. Marcovitz, McGrawHill Higher
Education
5
Lecture No 1
Introduction
(Logic Design)
In this lecture we will cover the following:
Logic Design
Number Systems
Binary, Octal, Decimal and Hexadecimal
Today’s Topics Number Systems
Examples
Positional Representation
Number Base Conversion
7
Logic Design
Digital Systems
Systems in which all the signals are represented by discrete
values. For example, Computers, Calculators, Digital Counter
(Odometer) etc.
Binary digital systems operate with two values; 0 (OFF) and
1(ON).
A digital system may have an arbitrary number of inputs
and an arbitrary number of outputs.
A W
B. . . . . Digital
..... X
System
n Inputs m Outputs
8
Number Systems
A number system is a set of numbers together with one or more
operations (e.g. add, subtract). Commonly used number systems
are decimal, binary, octal and hexadecimal number systems. All
these number systems are also called weighted number systems.
Integers are normally written using a position number system, in
which each digit represents the coefficient in a power series as
9
Binary Number System (Or Base-
2 System or Radix-2 System)
Binary number system is a different number system. This number
system has only two possible values i.e. 0 and 1.
The decimal equivalent of a binary number can be found by
multiplying coefficients of integral part by increasing powers of 2
(from right to left) and multiplying coefficients of fractional part by
decreasing powers of 2 (from left to right) and then adding all
these terms as:
……..+23 x a3 + 22x a2+21 x a1 +20 x a0 +2-1 x a-1 +2-2x a-2 + 2-3 x a-3 + 2-4 x
a-4 +…
where ……a4 a3 a2 a1 a0 . a-1 a-2 a-3 a-4……….. are coefficients of binary
number.
10
Octal Number System (Or Base-8
System or Radix-8 System)
This number system has only eight possible values i.e. 0, 1, 2, 3,
4 ,5 ,6 and 7.
The decimal equivalent of an octal number can be found by
multiplying coefficients of integral part by increasing powers of
8 (from right to left) and multiplying coefficients of fractional
part by decreasing powers of 8 (from left to right) and then
adding all these terms as:
……..+83 x a3 + 82x a2+81 x a1 +80 x a0 +8-1 x a-1 +8-2x a-2 + 8-3 x a-3 + 8-
4
x a-4 +…
where ……a4 a3 a2 a1 a0 . a-1 a-2 a-3 a-4……….. are coefficients of
octal number.
11
Hexadecimal Number System (Or
Base-16 System or Radix-16 System)
This number system has sixteen possible values i.e. 0, 1, 2, 3, 4 ,5 ,6,
7, 8, 9, A, B, C, D, E and F.
The decimal equivalent of a hexadecimal number can be found by
multiplying coefficients of integral part by increasing powers of 16
(from right to left) and multiplying coefficients of fractional part by
decreasing powers of 16 (from left to right) and then adding all these
terms as:
…..+163 x a3 + 162x a2+161 x a1 +160 x a0 +16-1 x a-1 +16-2x a-2 + 16-3 x a-3 +
16-4 x a-4 +…
where ……a4 a3 a2 a1 a0 . a-1 a-2 a-3 a-4……….. are coefficients of
hexadecimal number.
12
Numbers in Different
Systems
13
Positional Representation
The binary number 1101 represents the value:
V = 1x23 + 1x22 + 0x21 + 1x20
V = 8+4+1= 13
So
(1101)2 = (13)10
14
Number Base Conversion
To convert Decimal Numbers into Binary, follow these steps:
Step 1:
Divide the decimal number by 2 and record the remainder as the right
most bit (i.e. least significant bit) of the resulting binary number.
Step 2:
Divide the quotient obtained in previous step by 2 again and record
the remainder as the left bit to the remainder obtained in previous
step.
Step 3:
Repeat the step 2 until the quotient becomes less than the base and
record this remainder as the left most bit (i.e. most significant bit) of
the resulting binary number.
15
Number Base Conversion
(Contd...)
Example: convert the given Divide by 2 Result Remainder Binary Value
decimal number 294 into a binary 294 ÷ 2 147 0 0 (LSB)
number.
147 ÷ 2 73 1 1
Therefore, the binary equivalent for
73 ÷ 2 36 1 1
the given decimal number 29410 is
36 ÷ 2 18 0 0
1001001102
18 ÷ 2 9 0 0
9÷2 4 1 1
4÷2 2 0 0
2÷2 1 0 0
29410 =1001001102
1÷2 0 1 1 (MSB)
16
Number Base Conversion
(Contd...)
Important Note:
In order to convert the fractional part of a decimal number
into binary number, we use Fraction-Coefficient method.
In this method, fraction is first multiplied by the base (i.e. 2)
to get an integer and a fraction. We record this integer as
the first bit to the right of decimal point.
The new fraction is again multiplied by the base (i.e. 2) to
get a new fraction and a new integer. We record this new
integer as the next bit to the right of previous bit.
This process is continued until the fraction becomes 0 or
until the number of digits have sufficient accuracy.
17
Number Base Conversion
(Contd...)
Example:
Convert (0.6875)10 into binary.
18
Number Base Conversion
(Contd...)
To convert Decimal Numbers into Octal, follow these steps:
Step 1:
Divide the decimal number by 8 and record the remainder as the right most
digit (i.e. least significant digit) of the resulting octal number.
Step 2:
Divide the quotient obtained in previous step by 8 again and record the
remainder as the left digit to the remainder obtained in previous step.
Step 3:
Repeat the step 2 until the quotient becomes less than the base and record
this remainder as the left most digit (i.e. most significant digit) of the resulting
octal number.
19
Number Base Conversion
(Contd...)
Divide by 8 Result Remainder
Convert (624.513)10 into octal.
We shall first convert 624 into 624 / 8 78 0 (LSD)
octal. 78 / 8 9 6
9/8 1 1
So, (624)10 = (1160)8 1/8 0 1 (MSD)
20
Number Base Conversion
(Contd...)
Now, we shall convert the fractional part into octal as:
Fraction X Base = Coefficient(Integer) +Fraction
0.513 X 8 = 4 + 0.104
0.104 X 8 = 0 + 0.832
0.832 X 8 = 6 + 0.656
0.656 X 8 = 5 + 0.248
............
So, (0.513)10 = (0.4065….)8
21
Number Base Conversion
(Contd...)
To convert Decimal Numbers into Hexadecimal, follow the given steps:
Step 1:
Divide the decimal number by 16 and record the remainder as the right most
digit (i.e. least significant digit) of the resulting hexadecimal number.
Step 2:
Divide the quotient obtained in previous step by 16 again and record the
remainder as the left digit to the remainder obtained in previous step.
Step 3:
Repeat the step 2 until the quotient becomes less than the base and record
this remainder as the left most digit (i.e. most significant digit) of the resulting
hexadecimal number.
22
Number Base Conversion
(Contd...)
Example: Divide by Result Remainder
16
Convert (225.225)10 into hexadecimal. 225 / 16 14 1 (LSD)
We shall first convert 225 into 14 / 16 0 14 E
hexadecimal as: (MSD)
24
Number Base Conversion
(Contd...)
Example:
25
Number Base Conversion
(Contd...)
Conversion of Binary Numbers into Octal
For the integral part, make groups starting from right to left and for
fractional part, make groups starting from left to right.
26
Number Base Conversion
(Contd...)
Example:
= (17257.76)8
27
Number Base Conversion
(Contd...)
Conversion of Binary Numbers into Hexadecimal
In order to convert a binary number into its equivalent
hexadecimal number, make groups of four bits such that the
unformed group should be made by writing additional
zeros.
For the integral part, make groups starting from right to left
and for fractional part, make groups starting from left to
right.
Then write the hexadecimal equivalent of each group.
28
Number Base Conversion
(Contd...)
Example:
= (1EAF.F8)16
29
Number Base Conversion
(Contd...)
Conversion of Octal Numbers into Binary
30
Number Base Conversion
(Contd...)
Example:
= (10011001.100000110111)2
31
Number Base Conversion
(Contd...)
Conversion of Octal Numbers into Decimal
32
Number Base Conversion
(Contd...)
Example:
Convert the octal number (231.406)8 into decimal.
Solution:
(231.406)8 = 82x2 + 81x3 + 80x1 + 8-1x4 + 8-2x0 + 8-3x6
= 64 X 2 + 8 X 3 + 1 X 1 + 1/8 X 4 + 1/64 X 0
+ 512 X 6
= 128 + 24 + 1 + 0.5 + 0 + 0.0117
= 153.5117
33
Number Base Conversion
(Contd...)
Conversion of Octal Numbers into Hexadecimal
34
Number Base Conversion
(Contd...)
Example:
Convert the octal number (4073.062)8 into hexadecimal.
Solution:
We shall first convert octal into binary as
(4073.062)8 = (100 000 111 011 . 000 110 010) 2
4 0 7 3 0 6 2
=(100000111011.000110010)2
Now we shall convert binary into hexadecimal as
(100000111011.000110010)2=(1000 0011 1011 . 0001 1001 0000)2
= (83B.19) 16
35
Number Base Conversion (Contd...)
Number Base Conversion
(Contd...)
Conversion of Hexadecimal Numbers into Binary
36
Number Base Conversion (Contd...)
Number Base Conversion
(Contd...)
Example:
37
Number Base Conversion (Contd...)
Number Base Conversion
(Contd...)
Conversion of Hexadecimal Numbers into Decimal
38
Number Base Conversion (Contd...)
Number Base Conversion
(Contd...)
Example:
Convert the hexadecimal number (A043.DE)16 into decimal.
Solution:
(A043.DE)16 = 163xA + 162x0 + 161x4 + 160x3 + 16-1xD
+ 16-2x E
= 4096X10 + 0 + 16X4 + 1X3 + 1/16 X 13
+ 1/256 X 14
= 41027.8672
39
Number Base Conversion (Contd...)
Number Base Conversion
(Contd...)
Conversion of Hexadecimal Numbers into Octal
40
Number Base Conversion
(Contd...)
Example:
Convert the hexadecimal number (A04.DE)16 into octal.
Solution:
We shall first convert hexadecimal into binary as
(A04.DE)16 = (1010 0000 0100 . 1101 1110)2
A 0 4 D E = (101000000100.11011110)2
Now we shall convert binary into octal as
(101000000100.11011110)2=(101 000 000 100 . 110 111 100)2
5 0 0 4 6 7 4
= (5004.674)8
41
Bonus Round
42
Exercise
1. What is the decimal equivalent of binary numbers (101111)2
and (101.11)2
2. What is the decimal equivalent of Octal numbers (507)8
3. What is the decimal equivalent of Hexadecimal Number
(10AC.DF)16
43