1 Basics
1 Basics
(CSE 2003)
Lecture - 1
By
Dr. Daood Saleem
VIT Bhopal University
School of Computing Science and Engineering
Bhopal-Indore Highway
Kothri Kalan, Sehore-466114
Madhya Pradesh, India.
way, Kothri Kalan, Sehore, Madhya Pradesh – 466114
03/09/2025 09:05 AM 1
Text Books
03/09/2025 09:05 AM 2
Reference Books
03/09/2025 09:05 AM 3
Digital Logic
Digital logic is a branch of computer science that deals with
the design and implementation of digital circuits and systems.
It is mainly used for data representation and manipulation
using binary digits called bits. Digital logic is used in a wide
range of applications, including computer architecture, digital
electronics, and computer networking. Modern computing
system consists of complex system and technologies. These
technologies are built upon some fundamental simple logic
known as digital logic.
03/09/2025 09:05 AM 4
Why Digital Logic is Necessary ?
In modern computing domain, Digital logic plays a significant
role in many sectors which are discussed below:
1. Universal Representation: For any type of data
representation like image, text, video, audio etc. digital logic
is used by encoding the data into binary form. This binary
formatted data enables uniform handling of diverse data and
allows absolute integration and compatibility.
2. Scalability and Modularity: Digital logic provides scalable
framework by which we can develop complex system by
using basic logic gates only. This enables an easy and cost
effective way to develop a large-scale system with improved
flexibility, maintainability, and ease of integration.
03/09/2025 09:05 AM 5
Why Digital Logic is Necessary ?
3. Noise Immunity: A digital logic follows the discrete nature
of signal so it is less inclined to have induced noise compared
to analog signal. So it provides more robust communication
and data processing by noise filtering and error reduction.
4. Error Reduction and Correction: Digital logic is very less
inclined to error as it works with only two values called bits
(0 and 1). Moreover, we can employ redundancy check and
error detection mechanisms by digital logic codes which can
detect and rectify errors introduced during transmission. This
ensures reliable and accurate data processing.
03/09/2025 09:05 AM 6
Computer Architecture
Computer Architecture is a functional description of
requirements and design implementation for the various parts
of a computer. It deals with the functional behavior of
computer systems. It refers to the design of the internal
workings of a computer system, including the CPU, memory,
and other hardware components. It involves decisions about
the organization of the hardware, such as the instruction set
architecture, the data path design, and the control unit design.
Computer architecture is concerned with optimizing the
performance of a computer system and ensuring that it can
execute instructions quickly and efficiently.
03/09/2025 09:05 AM 7
Number Systems
Number System is a way to represent the numbers in the
computer architecture. There are four different types of the
number system, such as:
03/09/2025 09:05 AM 8
Decimal Number Systems
What does (5632)10 and (5632.25)10 represent ?
(5632)10 = 5x103+6x102+3x101+2x100 = 5000+600+30+2
(5632.25)10 = 5x103+6x102+3x101+2x100+2x10-1+5x10-2
= 5000+600+30+2+0.2+0.05
What is “10” called in above expansion ? The radix
What are the digits used for decimal number system ?
0,1,2,3,4,5,6,7,8,9
What are the digits for radix-r number systems ?
0, 1, 2,…, r-1.
Why do we use Decimal number system ?
03/09/2025 09:05 AM 9
Binary Number Systems
Binary numbers are made of binary digits (called bits):
0, 1
Binary number representation
(1110)2 = 1x23 + 1x22 + 1x21 + 0x20 =8+4+2+0= (14)10
(1110.11)2 = 1x23 + 1x22 + 1x21 + 0x20 + 1x2-1 + 1x2-2
= 14+0.5+0.25 = (14.75)10
Leftmost digit is called MSB (most significant bit)
Rightmost digit is called LSB (least significant bit)
03/09/2025 09:05 AM 10
Binary Number Systems
Groups of eight bits are called a byte: (11001001)2
Groups of four bits are called a nibble: (1101)2
1 KB = 210 Bytes = 1024 Bytes
1 MB = 210 KB = 220 Bytes
1 GB = 210 MB = 230 Bytes
1 TB = 210 GB = 240 Bytes
03/09/2025 09:05 AM 11
Why Use Binary Number System?
Easy to represent 0 and 1 using electrical values.
Possible to tolerate noise.
Easy to transmit data.
Easy to build binary circuits.
03/09/2025 09:05 AM 12
Octal Number Systems
Octal numbers are made of octal digits:
0, 1, 2, 3, 4, 5, 6, 7
Octal number representation
(4536)8 = 4x83 + 5x82 + 3x81 + 6x80 = 4x512+5x64+3x8+6x1
= 2048+320+24+6 = (2398)10
(4536.24)8 = 4x83 + 5x82 + 3x81 + 6x80+2x8-1+4x8-2
= 4x512+5x64+3x8+6x1+2x0.125+4x0.015625
= 2048+320+24+6+0.25+0.0625 = (2398.3125)10
Why do we use Octal number system ?
03/09/2025 09:05 AM 13
Hexadecimal Number Systems
Hexadecimal numbers are made of hexadecimal digits:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Hexadecimal number representation
(4CE5)16 = 4x163 + 12x162 + 14x161 + 5x160
= 4x4096+12x256+14x16+5x1
= 16384+3072+224+5 = (19685)10
(4CE5.A1)16 = 4x163 + 12x162 + 14x161 + 5x160 +10x16-1
+1x16-2 = 19685+10x0.0625+1x0.00390625
= 19685+0.62890625 = (19685.62890625)10
Why do we use Hexadecimal number system ?
03/09/2025 09:05 AM 14
Number Systems
Binary Octal Decimal Hexadecimal
Radix = 2 Radix = 8 Radix = 10 Radix = 16
Symbols are from Symbols are from Symbols are from Symbols are from
0,1. 0,1,2,3,4,5,6,7. 0,1,2,3,4,5,6,7,8,9. 0,1,2,3,4,5,6,7,8,9,
A,B,C,D,E,F.
Bit position value Bit position value Bit position value Bit position value
system. system. system. system.
03/09/2025 09:05 AM 15
Binary to Decimal Conversion
To convert binary to decimal, use decimal arithmetic to sum
the weighted powers of two:
Binary to Decimal conversion
(1110)2 = 1x23 + 1x22 + 1x21 + 0x20 =8+4+2+0= (14)10
(1110.10)2 = 1x23 + 1x22 + 1x21 + 0x20 + 1x2-1 + 0x2-2
= 14+0.5+0.25 = (14.75)10
03/09/2025 09:05 AM 16
Conversion between Bases
Convert the Integral part
Repeatedly divide the number by the radix you want to
convert to and save the remainders. The new radix digits are
the remainders in reverse order of computation.
Why does this work ?
This work because, the remainder left in the division is always
the coefficient of the radix’s exponent.
If the new radix is >= 10, then convert all remainders >= 10 to
digits A, B, C,…
03/09/2025 09:05 AM 17
Conversion between Bases
Convert the Fractional Part
Repeatedly multiply the fraction by the radix and save the
integer digits that result. The new radix fraction digits are the
integer numbers in computed order.
Why does this work?
To convert fractional part, it should be divided by reciprocal of
radix, which is same as multiplying with radix.
If the new radix is >= 10, then convert all integer numbers >=
10 to digits A, B, C…
Join together with the radix point.
03/09/2025 09:05 AM 18
Decimal to Binary Conversion
Example 1: Convert 46.687510 To Base 2 (Binary number or
radix 2).
Convert 46 to Base 2
46/2 = 23 remainder = 0
23/2 = 11 remainder = 1
11/2 = 5 remainder = 1
5/2 = 2 remainder = 1
2/2 = 1 remainder = 0
1/2 = 0 remainder = 1
Read off in reverse order: (101110)2
03/09/2025 09:05 AM 19
Decimal to Binary Conversion
Example 1: Convert 46.687510 To Base 2 (Binary number or
radix 2).
Convert 0.6875 to Base 2
0.6875*2 = 1.3750 integer = 1
0.3750*2 = 0.7500 integer = 0
0.7500*2 = 1.5000 integer = 1
0.5000*2 = 1.0000 integer = 1
0.0000
Read off in forward order: (0.1011)2
Join together with the radix point:(101110.1011)2
03/09/2025 09:05 AM 20
Conversion Among Octal,
Hexadecimal, Binary
Octal (Hexadecimal) to Binary:
Restate the octal (hexadecimal) as three (four) bit binary
digits, starting at radix point and going both ways.
Binary to Octal (Hexadecimal):
Group the binary digits into three (four) bit groups starting at
the radix point and going both ways, padding with zeros as
needed in the fractional part.
Convert each group of three (four) bits to an octal
(hexadecimal) digit.
03/09/2025 09:05 AM 21
Conversion Among Octal,
Hexadecimal, Binary
Example 2: Octal to Binary to Hexadecimal
635.1778
6 3 5 . 1 7 78
= 110|011|101.001|111|1112 = 110011101.0011111112
= 0001|1001|1101. 0011|1111|10002 (re-grouping)
= 19D.3F816 (converting)
03/09/2025 09:05 AM 22
r’s Complement
r’s complement of a number N is
rn - N
where,
r = radix of the number system
n = number of digit in given number
N = given number
Example 3: Find 10’s complement of (52520)10
r = 10, n = 5, N = 52520
10’s complement = rn - N = 105-52520 = 100000-52520
= 47480
03/09/2025 09:05 AM 23
(r-1)’s Complement
(r-1)’s complement of a number N is
(rn -1) - N
where,
r = radix of the number system
n = number of digit in given number
N = given number
Example 4: Find 9’s complement of (546700) 10
r = 10, n = 6, N = 546700
9’s complement is = (rn -1) - N = (106-1)-546700
= (1000000-1)-546700
= 999999-546700 = 453299
03/09/2025 09:05 AM 24
Numbers inside Computers
Since we only have 1s and 0s (charged/uncharged
transistors) in our computers, all numbers are represented in
binary.
A charged transistor represents bit 1, and an uncharged
transistor represents bit 0.
Unsigned and positive integers, are represented with bits
corresponding to their binary representations.
Negative integers, are represented using a format slightly
different from absolute values, as there are no negative signs
in transistors.
This format is called 2’s complement encoding.
03/09/2025 09:05 AM 25
How To Represent Signed Numbers
Plus and minus sign used for decimal numbers: 25 (or +25),
-16, etc.
Three types of signed binary number representations:
1. signed magnitude
2. 1's complement
3. 2's complement
A charged transistor represents bit 1, and an uncharged transistor
represents bit 0.
In each case: left-most bit indicates sign: positive (0) or negative (1).
000011002= 1210 100011002= -1210
Sign bit Magnitude
Signed bit represent in 4 bit, 8 bit, 12 bit etc.
03/09/2025 09:05 AM 26
1's Complement Representation
The 1's complement of a binary number involves inverting all bits.
1's comp of 00110011 is 11001100 (r = 2, n = 8, N = 00110011)
For an n bit number N the 1's complement is: (r n-1) - N
(rn-1) - N = (28-1) - 00110011 = 255 - 00110011
= 11111111
-00110011
11001100
To find negative of 1's complement number, take the 1's
complement.
000011002= 1210 111100112= -1210
Sign bit Magnitude
03/09/2025 09:05 AM 27
2's Complement Representation
The 2's complement of a binary number involves inverting all bits and
adding 1.
2's comp of 00110011 is 11001101 (r = 2, n = 8, N = 00110011)
For an n bit number N the 2's complement is: ((rn-1) - N)+1
((rn-1) - N)+1 = ((28-1) - 00110011) + 1 = (255 - 0 0 1 1 0 0 1 1) + 1
= 11001100
+ 1
11001101
To find negative of 2's complement number, take the 2's complement.
000011002= 1210 111101002= -1210
Sign bit Magnitude
Algorithm: Starting with the LSB, copy all of the bits up to and including
the first 1 bit and then complementing the remaining bits.
03/09/2025 09:05 AM 28
1's Complement Addition
Case I: Addition of a positive and a negative binary number.
In this case addition of numbers is performed after taking 1’s complement of
the negative number and the end around carry of the sum is added to the LSB.
Example 5: Find the sum of the following binary numbers using 1’s
complement.
+ 1110 and - 1101
+1 1 1 0 ⇒ 0 1 1 1 0
- 1 1 0 1 ⇒ 1 0 0 1 0 (taking 1’s complement)
00000
1 (end around carry)
00001
The sign bit is 0 and the magnitude bits of sum is 0001.
Hence the required sum is + 0001.
03/09/2025 09:05 AM 29
1's Complement Addition
Example 6: Find the sum of the following binary numbers using 1’s
complement.
+ 1010 and - 1100
+1 0 1 0 ⇒ 0 1 0 1 0
- 1 1 0 0 ⇒ 1 0 0 1 1 (taking 1’s complement)
1 1 1 0 1 (No end around carry is present)
The sign bit is 1 and 1’s complement of the magnitude bits of sum is 0010.
Hence the required sum is -0010.
Case II: When the two numbers are negative.
For the addition of two negative numbers 1’s complements of both the
numbers are to be taken and then added. In this case an end-around carry
will always appear and the end around carry of the sum is added to the
LSB.
03/09/2025 09:05 AM 30
1's Complement Addition
Example 7: Find the sum of the following binary numbers using
1’s complement.
- 1010 and - 0101
-1 0 1 0 ⇒ 1 0 1 0 1 (taking 1’s complement)
-0 1 0 1 ⇒ 1 1 0 1 0 (taking 1’s complement)
01111
1 (end around carry)
10000
The sign bit is 1 and 1’s complement of the magnitude bits of sum is
1111.
Hence the required sum is -1111.
For two positive numbers N and N’, it is summed with its binary
representation.
03/09/2025 09:05 AM 31
2's Complement Addition
Case I: Addition of a positive and a negative binary number.
In this case addition of numbers is performed after taking 2’s complement of
the negative number and the end around carry of the sum is discarded.
Example 8: Find the sum of the following binary numbers using 2’s
complement.
+ 1110 and - 1101
+1 1 1 0 ⇒ 0 1 1 1 0
- 1 1 0 1 ⇒ 1 0 0 1 1 (taking 2’s complement)
100001
(discard end around carry)
03/09/2025 09:05 AM 32
2's Complement Addition
Example 9: Find the sum of the following binary numbers using 2’s
complement.
+ 1010 and - 1100
+1 0 1 0 ⇒ 0 1 0 1 0
- 1 1 0 0 ⇒ 1 0 1 0 0 (taking 2’s complement)
1 1 1 1 0 (No end around carry is present)
The sign bit is 1 and 2’s complement of the magnitude bits of sum is
0010.
Hence the required sum is -0010.
Case II: When the two numbers are negative.
For the addition of two negative numbers 1’s complements of both the
numbers are to be taken and then added. In this case an end-around carry
will always appear and the end around carry of the sum is discarded.
03/09/2025 09:05 AM 33
2's Complement Addition
Example 10: Find the sum of the following binary numbers using
2’s complement.
- 1010 and - 0101
-1 0 1 0 ⇒ 1 0 1 1 0 (taking 2’s complement)
-0 1 0 1 ⇒ 1 1 0 1 1 (taking 2’s complement)
110001
(discard end around carry)
The sign bit is 1 and 2’s complement of the magnitude bits of sum is
1111.
Hence the required sum is -1111.
For two positive numbers N and N’, it is summed with its binary
representation.
03/09/2025 09:05 AM 34