0% found this document useful (0 votes)
4 views68 pages

Chapter_1_-_Number_Systems_db_edit

The document discusses number systems, particularly focusing on the binary number system, which is essential in digital electronics. It explains the classification of number systems based on their base or radix, and provides methods for converting between binary and decimal representations. Additionally, it covers binary arithmetic operations such as addition and subtraction, as well as conversions to and from octal numbers.

Uploaded by

vedanshmadan207
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views68 pages

Chapter_1_-_Number_Systems_db_edit

The document discusses number systems, particularly focusing on the binary number system, which is essential in digital electronics. It explains the classification of number systems based on their base or radix, and provides methods for converting between binary and decimal representations. Additionally, it covers binary arithmetic operations such as addition and subtraction, as well as conversions to and from octal numbers.

Uploaded by

vedanshmadan207
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 68

Chapter 1:

Number Systems
Number System
• A system that is used for representing numbers is called the
number system.
• In Digital Electronics, the numbers are used to represent the
information.
• Hence, it is important to learn and understand different types
of number systems so we can easily represent and interpret
the information in the form of numbers.
• There are several types of number systems and the basis of
this classification is the base or radix of the number system.
• The base or radix of the number system is the total number of
symbols used to denoted the numbers in the number system.

ECL 102 – Digital Electronics 2


Dr. Mayank Thacker
Number System
• Depending on the base or radix, number systems can be
classified into the following four major types −
• Binary Number System (Base 2) (Numbers 0 and 1)
• Octal Number System (Base 8) (Numbers 0 – 7)
• Decimal Number System (Base 10) (Numbers 0 – 9)
• Hexadecimal Number System (Base 16) (Numbers 0 – 9
and A – F)
• The numbers are represented by using the weights to
the base of the number system.
• Ex – For a number abc.de - 𝑥 2 + 𝑥 1 + 𝑥 0 + 𝑥 −1 + 𝑥 −2

ECL 102 – Digital Electronics 3


Dr. Mayank Thacker
Binary Number System
• All modern digital devices like computers, combinational
circuits, sequential circuits, etc. use the binary number system
to operate.
• The position of a 1 or 0 in a binary number indicates its weight,
or value within the number, just as the position of a decimal
digit determines the value of that digit.

ECL 102 – Digital Electronics 4


Dr. Mayank Thacker
Binary Number System
• The decimal numbers from 0 – 15 are Decimal
(base 10)
Binary
(base 2)
represented in equivalent binary as: 0 0000
1 0001
• As you have seen in above Table, four bits 2 0010
3 0011
are required to count from zero to 15. 4 0100

• In general, with ‘n’ bits you can count up to 5


6
0101
0110
a number equal to 2𝑛 − 1. 7 0111
8 1000
• Ex – for n = 5 25 − 1 = 32 − 1 = 31 9 1001
10 1010
• Ex – for n = 6 26 − 1 = 64 − 1 = 63 11 1011
12 1100
13 1101
14 1110
15 1111

ECL 102 – Digital Electronics 5


Dr. Mayank Thacker
Binary Number System
• A binary number is a weighted number.
• The right-most bit is the LSB (least significant bit) in a binary
whole number and has a weight of 20 = 1.
• The weights increase from right to left by a power of two for
each bit.
• The left-most bit is the MSB (most significant bit) its weight
depends on the size of the binary number.
• Fractional numbers can also be represented in binary by
placing bits to the right of the binary point.
• MSB of binary fractional number has weight of 2−1 = 0.5.

ECL 102 – Digital Electronics 6


Dr. Mayank Thacker
Binary Number System
• Convert the binary number 1101101 into equivalent decimal.

• Solution
Number of Digits – 7, max power is 6.
Weight: 26 25 24 23 22 21 20
Binary Number: 1 1 0 1 1 0 1
1101101 = 26 + 25 + 23 + 22 + 20
= 64 + 32 + 8 + 4 + 1 = 109

ECL 102 – Digital Electronics 7


Dr. Mayank Thacker
Binary Number System
• Convert the binary number 0.1011 into equivalent decimal.

• Solution

Weight: 2−1 2−2 2−3 2−4


Binary Number: 0.1 0 1 1
0.1011 = 2−1 + 2−3 + 2−4
= 0.5 + 0.125 + 0.0625 = 0.6875

ECL 102 – Digital Electronics 8


Dr. Mayank Thacker
Binary Number System
• Convert the following binary number into decimal
• (110 0100)2
Running sum
1x 0 = 0 0
2x 0 = 0 0
4x 1 = 4 4 (110 0100)2 = (100)10
8x 0 = 0 4
16 x 0 = 0 4
32 x 1 = 32 36
64 x 1 = 64 100

ECL 102 – Digital Electronics 9


Dr. Mayank Thacker
Binary Number System
• Decimal to Binary Conversion
• For decimal whole number we will use repeated division-by-2
method and
• For decimal fractional number we will use repeated
multiplication-by-2 method.

ECL 102 – Digital Electronics 10


Dr. Mayank Thacker
Binary number representation
• Convert (19)10 into binary
Remainder
19 / 2 = 9 1 LSB (Least Significant Bit)
9/ 2 = 4 1
4/ 2 = 2 0
2/ 2 = 1 0
1/ 2 = 0 1
MSB (Most Significant Bit)

(19)10 = (1 0011)2

ECL 102 – Digital Electronics 11


Dr. Mayank Thacker
Binary number representation
• Convert (45)10 into binary
Remainder
45 / 2 = 22 1 LSB (Least Significant Bit)
22 / 2 = 11 0
11 / 2 = 5 1
5/ 2 = 2 1
2/ 2 = 1 0
1/ 2 = 0 1 MSB (Most Significant Bit)

(45)10 = (10 1101)2

ECL 102 – Digital Electronics 12


Dr. Mayank Thacker
Binary number representation
• What is the minimum number of “bits” required to represent (290)10
CHECK!
Check
290 / 2 = 145 0 LSB 256 x 1 = 256 256
145 / 2 = 72 1 128 x 0 = 0 256
72 / 2 = 36 0 64 x 0 = 0 256
36 / 2 = 18 0 32 x 1 = 32 288
18 / 2 = 9 0 16 x 0 = 0 288
9/ 2 = 4 1 8x 0 = 0 288
4/ 2 = 2 0 4x 0 = 0 288
2/ 2 = 1 0 2x 1 = 2 290
1/ 2 = 1 1 MSB 1x 0 = 0 290
• (290)10 = (1 0010 0010)2 – a minimum of 9 bits

ECL 102 – Digital Electronics 13


Dr. Mayank Thacker
Binary number representation
• What is the minimum number of “bits” required to
represent (290)10
290 ≤ 2𝑛

log 290 ≤ log 2𝑛 log 290 ≤ 𝑛 × log 2


log 290 log 290
≤𝑛 𝑛≥ = 8.18
log 2 log 2

• Need 9 bits

ECL 102 – Digital Electronics 14 Finished 08-10-2025


Dr. Mayank Thacker
Binary Number System
• To convert the decimal fraction to binary, we begin by
multiplying the fraction by 2 and then multiplying
each resulting fractional part of the product by 2 until
the fractional product is zero or until the desired
number of decimal places is reached.
• The carry digits, or carries, generated by the
multiplications produce the binary number.
• The first carry produced is the MSB, and the last carry
is the LSB.

ECL 102 – Digital Electronics 15


Dr. Mayank Thacker
Binary number representation
• Convert (0.3125)10 into binary

Carry MSB (Most Significant Bit)


0.3125 x 2 = 0.625 0
0.625 x 2 = 1.25 1
0.25 x 2 = 0.5 0
0.5 x 2 = 1 1
LSB (Least Significant Bit)

(0.3125)10 = (0.0101)2

ECL 102 – Digital Electronics 16


Dr. Mayank Thacker
Binary number representation
• Convert (85.375)10 into binary
Remainder
85 / 2 = 42 1 LSB Carry MSB
0.375 x 2 = 0.75 0
42 / 2 = 21 0
0.75 x 2 = 1. 5 1
21 / 2 = 10 1
0.5 x 2 = 1 1
10 / 2 = 5 0 LSB

5/ 2 = 2 1
2/ 2 = 1 0
1/ 2 = 0 1
MSB

(0.3125)10 = (1010101.011)2

ECL 102 – Digital Electronics 17


Dr. Mayank Thacker
Binary Arithmetic - Addition
• The four basic rules for adding binary digits (bits) are as
follows:
𝒂 𝟎 0 𝟏 𝟏
+𝒃 +𝟎 +𝟏 +𝟎 +𝟏
𝒔𝟏 𝒔𝟎 𝟎 𝟎 𝟎 𝟏 𝟎 𝟏 𝟏 𝟎

• Notice that the first three rules result in a single bit result (no
carry). In the fourth rule, the addition of two 1s yields a binary
two (10 – carry is generated).

ECL 102 – Digital Electronics 18


Dr. Mayank Thacker
Binary Arithmetic - Addition
• Add the following binary numbers: 𝐺𝑒𝑛𝑒𝑟𝑎𝑡𝑒𝑑 𝑐𝑎𝑟𝑟𝑖𝑒𝑠
1 1 1 0
𝑋 = 𝑥4 𝑥3 𝑥2 𝑥1 𝑥0 0 1 1 1 1 (15)10
+ 𝑌 = 𝑦4 𝑦3 𝑦2 𝑦1 𝑦0 +0 1 0 1 0 + (10)10
𝑆 = 𝑠4 𝑠3 𝑠2 𝑠1 𝑠0 1 1 0 0 1 + (25)10

𝟏𝟏 𝟏𝟎𝟎 𝟏𝟏𝟏 𝟏𝟏𝟎


+𝟏𝟏 +𝟏𝟎 +𝟏𝟏 +𝟏𝟎𝟎
𝟏𝟏𝟎 𝟏𝟏𝟎 𝟏𝟎𝟏𝟎 𝟏𝟎𝟏𝟎

ECL 102 – Digital Electronics 19


Dr. Mayank Thacker
Binary Arithmetic - Subtraction
• The four basic rules for subtracting binary digits (bits) are as
follows:
𝒂 𝟎 1 𝟏 𝟎
−𝒃 −𝟎 −𝟏 −𝟎 −𝟏
𝒔𝟏 𝒔𝟎 𝟎 𝟎 𝟎 𝟎 𝟎 𝟏 𝟏 𝟏

• Subtract 011 from 101


𝟏𝟎𝟏
−𝟎𝟏𝟏
𝟎𝟏𝟎

ECL 102 – Digital Electronics 20


Dr. Mayank Thacker
Octal number representation
• Convert (153)10 into Octal
Remainder
153 / 8 = 19 1 LSB (Least Significant Bit)
19 / 8 = 2 3 (153)10 = (231)8
2/ 8 = 0 2 MSB (Most Significant Bit)

ECL 102 – Digital Electronics 21


Dr. Mayank Thacker
Octal number representation
• Convert (0.513)10 into Octal
Carry MSB
0.513 x 8 = 4.104 4
kitne pe stop karna hai
0.104 x 8 = 0.832 0
0.832 x 8 = 6.656 6
0.656 x 8 = 5.248 5
0.248 x 8 = 1.984 1
0.984 x 8 = 7.872 7 LSB

(0.3125)10 = (0.40651….)8

ECL 102 – Digital Electronics 22


Dr. Mayank Thacker
Octal number representation
• Convert the binary number 1101101 into equivalent Octal.

• Form groups of 3 bits and have the equivalent octal number

dono methods se kar sakte


1 101 101 001 101 101 pehle to decimals and then to octal we can
do
BUT
jitna base hai utni agar vo 2 ki power n me

1 5 5 likh sakte h
toh then we have to make pair of n of that
binary code and then evaluate that block of
binary chunk

(1101101)2 = (155)8

ECL 102 – Digital Electronics 23


Dr. Mayank Thacker
Number System and equivalents
Decimal Binary Octal Hexadecim Decimal Binary Octal Hexadecim
(base 10) (base 2) (base 8) al (base 16) (base 10) (base 2) (base 8) al (base 16)
0 0000 0 0 8 1000 10 8
1 0001 1 1 9 1001 11 9
2 0010 2 2 10 1010 12 A
3 0011 3 3 11 1011 13 B
4 0100 4 4 12 1100 14 C
5 0101 5 5 13 1101 15 D
6 0110 6 6 14 1110 16 E
7 0111 7 7 15 1111 17 F

ECL 102 – Digital Electronics 24


Dr. Mayank Thacker
Hexadecimal number representation
• Convert the binary number 1101011101101 into equivalent
Hexadecimal.
see 2^N
where n is 4 cause 2^4 is 16 tyhat is the base

• Form groups of 4 bits and have the equivalent Hex number

1 1010 1110 1101 0001 1010 1110 1101

1 A E D

(1101011101101)2 = (1AED)16

ECL 102 – Digital Electronics 25


Dr. Mayank Thacker
Hexadecimal number representation
• Convert (1228)10 and (600)10 into Hexadecimal
Remainder
1228 / 16 = 76 12 LSB (Least Significant Bit)
76 / 16 = 4 12 (1228)10 = (4CC)16
4 / 16 = 0 4 MSB (Most Significant Bit)

Remainder
600 / 16 = 37 8 LSB (Least Significant Bit)
37 / 16 = 2 5 (600)10 = (258)16
2 / 16 = 0 2 MSB (Most Significant Bit)

ECL 102 – Digital Electronics 26


Dr. Mayank Thacker
Hexadecimal number representation
• Convert (E5)16 and (B2F8)16 into Decimal

𝐸516 = 𝐸 × 16 + (5 × 1) = 14 × 16 + (5 × 1) = 224 + 5 = 22910

𝐵2𝐹816 = 𝐵 × 4096 + 2 × 256 + 𝐹 × 16 + (8 × 1)


= 11 × 4096 + 2 × 256 + 15 × 16 + (8 × 1)
= 45056 + 512 + 240 + 8
= 4581610

ECL 102 – Digital Electronics 27 Finished 13-01-2025


Dr. Mayank Thacker
Any base number representation
• A number can be converted to a number of any other base.
• If the base of number system is 𝑥, then the total number of
single digits is 0 to (𝑥 − 1).
• Ex – if the base of the number system is 5, the single digit
numbers are 0 to 4.

means binary me base 2 hai toh khali do hi nymber se number bana sakte h ham
like 0 or 1
same in base 8 where the number is formed contains only 0-7

ECL 102 – Digital Electronics 28


Dr. Mayank Thacker
Any base number representation
• Convert (678)10 = (?)5 and (323)10 = (?)5
Remainder
678 / 5 = 135 3 LSB (Least Significant Bit)
135 / 5 = 27 0 (678)10 = (10203)5
27 / 5 = 5 2
5/ 5 = 1 0 MSB (Most Significant Bit)
1/ 5 = 0 1

Remainder
323 / 5 = 64 3 LSB (Least Significant Bit)
64 / 5 = 12 4 (323)10 = (2243)5
12 / 5 = 2 2
2/ 5 = 0 2 MSB (Most Significant Bit)

ECL 102 – Digital Electronics 29


Dr. Mayank Thacker
Any base number representation
• If it is asked to convert from base 16 to any other base system,
convert to decimal first and then to the desired base system.
• Convert (1C)16 = (?)5
1𝐶16 = 1 × 16 + (𝐶 × 1) = 1 × 16 + (12 × 1) = 16 + 12 = 2810

Remainder
28 / 5 = 5 3 LSB (Least Significant Bit)
5/ 5 = 1 0 (1C)16 = (103)5
1/ 5 = 0 1
MSB (Most Significant Bit)

ECL 102 – Digital Electronics 30


Dr. Mayank Thacker
Any base number representation
• Consider the equation (123)5 = (𝑥8)𝑦 . Find the value of x and
y. importantttttttt

1235 = 1 × 25 + 2 × 5 + (3 × 1) = 𝑥𝑦 + 8

∴ 38 = 𝑥𝑦 + 8 ∴ 𝑥𝑦 = 30

• To have the numbers satisfy the equation, y (base) > x


∴ 𝑥 = 1, 𝑦 = 30 ∴ 𝑥 = 5, 𝑦 = 6
∴ 𝑥 = 2, 𝑦 = 15
∴ 𝑥 = 3, 𝑦 = 10 • Other combinations are invalid.

ECL 102 – Digital Electronics 31


Dr. Mayank Thacker
Any base number representation
• Consider the equation (43)𝑥 = (𝑦3)8 . Find the value of x and y.
43𝑥 = 4 × 𝑥 + 3 = 8𝑦 + 3

∴ 4𝑥 = 8𝑦 ∴ 𝑥 = 2𝑦
• To have the numbers satisfy the equation, 4 < x(base) and y < 8
(base)
∴ 𝑥 = 6, 𝑦 = 3 ∴ 𝑥 = 14, 𝑦 = 7
∴ 𝑥 = 8, 𝑦 = 4
∴ 𝑥 = 10, 𝑦 = 5
∴ 𝑥 = 12, 𝑦 = 6

ECL 102 – Digital Electronics 32


Dr. Mayank Thacker
Negative Binary numbers
• Negative numbers can be represented in following
ways
• Sign and magnitude
• 1’s complement
• 2’s complement
• Sign and magnitude
• As before MSB is the “sign” bit
+5 = 0101 −5 = 1101
• Easy to understand – but not well suited for computing

ECL 102 – Digital Electronics 33


Dr. Mayank Thacker
1’s complement
• “Complementary” number system
• Addition of Negative numbers determined by subtraction
of positive numbers
• “1’s complement”
• n-bit -ve number 𝐾 obtained by subtracting equivalent
positive number 𝑃 from 2𝑛 − 1 𝐾 = 2𝑛 − 1 − 𝑃
• Example for 𝑛 = 4 𝐾 = 24 − 1 − 𝑃
= 1510 − 𝑃 = 1111 2 −𝑃

ECL 102 – Digital Electronics 34


Dr. Mayank Thacker
1’s complement
• Example converting +5 to -5 𝐾 = 2𝑛 − 1 − 𝑃
2𝑛 − 1 𝑃 𝐾
𝟏𝟓 +𝟓 −𝟓

−5 = 1111 − 0101 = 1010 −𝑣𝑒 +𝑣𝑒

• Converting +3
2𝑛 − 1 𝑃 𝐾
𝟏𝟓 +3 −3
−3 = 1111 − 0011 = 1100
1’s compliment

• Result is compliment of each bit of +ve number


• However ….there are still some issues with arithmetic

ECL 102 – Digital Electronics 35


Dr. Mayank Thacker
1’s complement
• Find 1s complement of +12
2𝑛 − 1 𝑃 𝐾
𝟑𝟏 +12 −12
−12 = 11111 − 01100= 10011
1’s compliment

ECL 102 – Digital Electronics 36


Dr. Mayank Thacker
2’s complement
• “2’s complement”
• n-bit -ve number 𝐾obtained by subtracting equivalent
positive number 𝑃 from 2𝑛 𝐾 = 2𝑛 − 𝑃

• Example for 𝑛 = 4 𝐾 = 24 − 𝑃
= 1610 − 𝑃 = 10000 2 −𝑃

ECL 102 – Digital Electronics 37


Dr. Mayank Thacker
2’s complement
• Example converting +5 to -5 𝐾 = 2𝑛 − 𝑃
2𝑛 𝑃 𝐾
𝟏6 +𝟓 −𝟓

−5 = 10000 − 0101 = 1011 −𝑣𝑒 +𝑣𝑒

• Converting +3 to -3
2𝑛 𝑃 𝐾
𝟏6 +3 −3
−3 = 10000 − 0011 = 1101

• Involves subtraction with “borrows”

ECL 102 – Digital Electronics 38


Dr. Mayank Thacker
2’s complement
• Observe that if 𝐾1 is the 1’s complement and 𝐾2 is the
2’s complement then 𝐾1 = 2𝑛 − 1 − 𝑃 … … 1′ 𝑠
𝐾2 = 2𝑛 − 𝑃 … … 2′ 𝑠
• If follows that 𝐾2 = 𝐾1 + 1

• Simpler way to get 2’s complement


• 1’s complement (invert each bit)
• Add 1

ECL 102 – Digital Electronics 39


Dr. Mayank Thacker
Rule for finding 2’s complement
• Give a number 𝐵 = 𝑏𝑛−1 𝑏𝑛−2 ⋯ 𝑏1 𝑏0
• 2’s complement 𝐾 = 𝑘𝑛−1 𝑘𝑛−2 ⋯ 𝑘1 𝑘0 can be found by
• Examine B from right to left
• Copy all the bits that are 0 and the first 1, then compliment
the rest of the bits
• Example 𝐵 = 0110 ….. from right to left
𝑘0 = 𝑏0 = 0 𝑘1 = 𝑏1 = 1 𝑘2 = 𝑏2 = 0 𝑘3 = 𝑏3 = 1

𝐾 = 1010

ECL 102 – Digital Electronics 40


Dr. Mayank Thacker
2’s complement
• Find 2s complement of +12

From 1s complement method


2𝑛 − 1 𝑃 𝐾 𝐾+1
𝟑𝟏 +12 −12 −12
−12 = 11111 − 01100 = 10011 = 10100
1’s compliment 2’s compliment

From inversion 𝐾method


+1
−12
𝐵 = 01100 = 10100

ECL 102 – Digital Electronics 41


Dr. Mayank Thacker
Addition of Signed Binary Numbers
• Signed binary numbers can be added under 4
categories
• Both numbers positive
• Positive number with magnitude larger than negative
number
• Negative number with magnitude larger than positive
number
• Both numbers negative

• We discard the carry generated after addition

ECL 102 – Digital Electronics 42


Dr. Mayank Thacker
Addition of Signed Binary Numbers – Both
numbers positive
• Add the binary numbers 0000_0111 and 0000_0100.

0 0 0 0 100
0 0 0 0 01 1 1 (7)10
+0 0 0 0 0 1 0 0 + (4)10
00 00 1 0 1 1 + (11)10

• The MSB bit is 0, hence result is positive or can say as


non-complemented binary.

ECL 102 – Digital Electronics 43


Dr. Mayank Thacker
Addition of Signed Binary Numbers –
Positive number > Negative number
• Add the numbers 15 and -6 in binary format.

1 11 1 1 1 0
0 0 0 0 1 1 1 1 (15)10
+1 1 1 1 1 0 1 0 + (−6)10
1 0 0 00 1 0 0 1 + (9)10

• The carry is generated, ignore


• The MSB bit is 0, hence result is positive or can say as
non-complemented binary.

ECL 102 – Digital Electronics 44


Dr. Mayank Thacker
Addition of Signed Binary Numbers –
Positive number < Negative number
• Add the numbers 16 and -24 in binary format.

0 00 0 0 0 0
0 0 0 1 0 0 0 0 (16)10
+1 1 1 0 1 0 0 0 + (−24)10
0 1 1 11 1 0 0 0 + (−8)10

• The carry is not generated


• The MSB bit is 1, hence result is Negative and is in 2s
complement form. Take 2s complement again to get
magnitude of number

ECL 102 – Digital Electronics 45


Dr. Mayank Thacker
Addition of Signed Binary Numbers –Both
numbers are negative
• Add the numbers -5 and -9 in binary format.

1 11 1 1 1 1
1 1 1 1 1 0 1 1 (−5)10
+1 1 1 1 0 1 1 1 + (−9)10
1 1 1 11 0 0 1 0 + (−14)10

• The carry is generated, ignore


• The MSB bit is 1, hence result is Negative and is in 2s
complement form. Take 2s complement again to get
magnitude of number

ECL 102 – Digital Electronics 46


Dr. Mayank Thacker
Subtraction of Signed Binary Numbers
• Subtraction of signed binary numbers is a special
case of addition.
• Ex- If we want to subtract +6 from +9. Then we can
have addition of -6 with +9. Number -6 will be
represented in 2s complement form.

ECL 102 – Digital Electronics 47


Dr. Mayank Thacker
Subtraction of Signed Binary Numbers
• Perform the following operation on binary numbers:
A. 0000_1000 – 0000_0011
B. 0000_1100 – 1111_0111
C. 1110_0111 – 0001_0011
D. 1000_1000 – 1110_0010

ECL 102 – Digital Electronics 48


Dr. Mayank Thacker
Subtraction of Signed Binary Numbers
• Perform the following operation on binary numbers:
A. 0000_1000 – 0000_0011  8 – 3  8 + (-3)
1 11 1 0 0 0
0 0 0 0 1 0 0 0
+1 1 1 1 1 1 0 1
1 0 0 00 0 1 0 1

• The carry is generated, ignore


• The MSB bit is 0, hence result is positive or can say as
non-complemented binary (5).

ECL 102 – Digital Electronics 49


Dr. Mayank Thacker
Subtraction of Signed Binary Numbers
• Perform the following operation on binary numbers:
B. 0000_1100 – 1111_0111  12 – (-9)  12+ (9)
0 00 1 0 0 0
0 0 0 0 1 1 0 0
+0 0 0 0 1 0 0 1
0 0 0 01 0 1 0 1

• The carry is not generated


• The MSB bit is 0, hence result is positive or can say as
non-complemented binary (21).

ECL 102 – Digital Electronics 50


Dr. Mayank Thacker
Subtraction of Signed Binary Numbers
• Perform the following operation on binary numbers:
C. 1110_0111 – 0001_0011  -25 – (+19)  -25 + (-19)
1 10 1 1 1 1
1 1 1 0 0 1 1 1
+1 1 1 0 1 1 0 1
1 1 1 01 0 1 0 0

• The carry is generated, ignore


• The MSB bit is 1, hence result is Negative and is in 2s
complement form. Take 2s complement again to get
magnitude of number (-44)

ECL 102 – Digital Electronics 51


Dr. Mayank Thacker
Subtraction of Signed Binary Numbers
• Perform the following operation on binary numbers:
D. 1000_1000 – 1110_0010  -120 – (-30)  -120 + (30)
0 01 1 0 0 0
1 0 0 0 1 0 0 0
+0 0 0 1 1 1 1 0
0 1 0 10 0 1 1 0

• The carry is not generated


• The MSB bit is 1, hence result is Negative and is in 2s
complement form. Take 2s complement again to get
magnitude of number (-90)

ECL 102 – Digital Electronics 52 Finished 14-01-2025


Dr. Mayank Thacker
Binary Coded Decimal (BCD)
• BCD is a way to express each of the decimal digits with a binary
code.
• Binary coded decimal means that each decimal digit, 0 through
9, is represented by a binary code of four bits.
• The 8421 code is a type of BCD (binary coded decimal) code.
• The designation 8421 indicates the binary weights of the four
bits (23 , 22 , 21 , 20 ).
• The 8421 code is the predominant BCD code, and when we
refer to BCD, we always mean the 8421 code unless otherwise
stated.

ECL 102 – Digital Electronics 53


Dr. Mayank Thacker
Binary Coded Decimal (BCD)
• The six code combinations — 1010, 1011, 1100, 1101, 1110,
and 1111 — are invalid in the 8421 BCD code.
• Note that BCD and binary representation of decimal number
are two different things.
• We go for BCD because binary is less human readable. This can
be understood from example.
• 63 in Binary is 0011 1111
63 in BCD is 0110 0011
• 597 in Binary is 0010 0101 0101
597 in BCD is 0101 1001 0111

ECL 102 – Digital Electronics 54


Dr. Mayank Thacker
BCD addition
• Perform the BCD arithmetic, 8 + 4 and 8 + 9

0 0 0 0 0 0
(8)10 1 0 0 0 1 0 0 0 (8)10
+ (4)10 +0 1 0 0 +1 0 0 1 + (9)10
+ (12)10 1 1 0 0 Invalid BCD 1 0 0 0 1 + (17)10
+0 1 1 0 +0 1 1 0
10 0 0 0 0
1 0 0 10 1 0 1 1 1

ECL 102 – Digital Electronics 55


Dr. Mayank Thacker
BCD addition
• Perform the BCD arithmetic, 184 + 576
0 01 0 0 0 0 0 1 0 0
(184)10 0 0 0 1 1 0 0 0 0 1 0 0
+ (576)10 +0 1 0 1 0 1 1 1 0 1 1 0
+ (760)10 0 0 1 1 0 1 1 1 1 1 0 1 0 Invalid BCD

+0 0 0 0 0 1 1 0 0 1 1 0
0 0 01 1 1 1 1 11 0
0 1 11 0 1 1 0 0 0 0 0 Valid BCD

• IMP=> The nibble that has produced a carry or is grater than


1001, add 0110 with it.

ECL 102 – Digital Electronics 56


Dr. Mayank Thacker
9s and 10s Complement
• The 9s complement of a number is found by subtracting each
of the number from 9.
• This is used to represent negative number. Just like 1s
complement in binary.
• This way, it becomes easier to represent the negative BCD
numbers and to perform arithmetic on them.
• 10s complement is found by adding 1 to 9s complement of a
number.

ECL 102 – Digital Electronics 57


Dr. Mayank Thacker
9s and 10s complement
• Perform the arithmetic using 10s complement method,
375 + (-240)

9s complement of 240
1 0
9 9 9 3 7 5
− 2 4 0 + 7 6 0
+ 7 5 9 1 1 3 5
+ 1 Ignore the carry generated,
+ 7 6 0 result if 135.
10s complement of 240

ECL 102 – Digital Electronics 58


Dr. Mayank Thacker
Other Decimal codes
Decimal digit BCD 8421 2421 Excess-3 8,4,-2,-1
0 0000 0000 0011 0000
1 0001 0001 0100 0111
2 0010 0010 0101 0110
3 0011 0011 0110 0101
4 0100 0100 0111 0100
5 0101 1011 1000 1011
6 0110 1100 1001 1010
7 0111 1101 1010 1001
8 1000 1110 1011 1000
9 1001 1111 1100 1111

ECL 102 – Digital Electronics 59


Dr. Mayank Thacker
Gray codes
• It is many a times convenient to transmit the data in serial
format.
• The binary data transmission may lead to erroneous data
reception.
• To get rid of this gray codes are introduced.
• Only one bit changes at a time, when going incrementing or
decrementing numbers, unlike in any other format.

ECL 102 – Digital Electronics 60


Dr. Mayank Thacker
Gray codes
• Comparison of the binary and gray code is given in table

Decimal Binary Gray Decimal Binary Gray


(base 10) (base 2) code (base 10) (base 2) code
0 0000 0000 8 1000 1100
1 0001 0001 9 1001 1101
2 0010 0011 10 1010 1111
3 0011 0010 11 1011 1110
4 0100 0110 12 1100 1010
5 0101 0111 13 1101 1011
6 0110 0101 14 1110 1001
7 0111 0100 15 1111 1000

ECL 102 – Digital Electronics 61 Finished 20-01-2025


Dr. Mayank Thacker
Gray codes
• Binary to gray conversion
𝐵𝑛 𝐵𝑛−1 𝐵𝑛−2 … 𝐵1 ≅ 𝐺𝑛 𝐺𝑛−1 𝐺𝑛−2 … 𝐺1
𝐺𝑛 = 𝐵𝑛
𝐺𝑛−1 = 𝐵𝑛 ⊕ 𝐵𝑛−1
A B Y
𝐺𝑛−2 = 𝐵𝑛−1 ⊕ 𝐵𝑛−2
0 0 0
0 1 1 …
𝐺1 = 𝐵2 ⊕ 𝐵1
1 0 1
1 1 0

ECL 102 – Digital Electronics 62


Dr. Mayank Thacker
Gray codes
• Convert binary numbers 110011, 101101 to gray

Solution
1 0 1 0 1 0 1 1 1 0 1 1

A B Y
Self-study gray to binary.
0 0 0
0 1 1
1 0 1
1 1 0

ECL 102 – Digital Electronics 63


Dr. Mayank Thacker
XS-3 addition
• Represent the numbers to be added in Excess 3 form.
• Add the two numbers using basic laws of binary addition.

• IMP=> The nibble that has produced a carry, add 0011 with it
and subtract 0011 from the nibble that has not.

ECL 102 – Digital Electronics 64


Dr. Mayank Thacker
XS-3 addition
• Perform the XS-3 addition on, 356 and 579

0 00 1 0 0 0 1 0 0 0
(356)10 0 1 1 0 1 0 0 0 1 0 0 1
+ (579)10 +1 0 0 0 1 0 1 0 1 1 0 0
+ (935)10 0 1 1 1 1 0 0 1 1 0 1 0 1 Invalid XS-3

−/+ 0 0 1 1 0 0 1 1 0 0 1 1
0 0 00 0 1 1 0 11 1
1 1 00 0 1 1 0 1 0 0 0 Valid XS-3

ECL 102 – Digital Electronics 65


Dr. Mayank Thacker
Overflow in binary arithmetic
• When two numbers are added and the number of bits required
to represent the sum exceeds the number of bits in the two
numbers, an overflow occurs.
• Alternately, if result exceeds the range 0 to 2𝑛 − 1 , an
overflow occurs.
0 0 0
• Ex – Add two binary numbers (9)10 1 0 0 1
+ (8)10 +1 0 0 0
+ (17)10 1 0 0 0 1

Overflow

ECL 102 – Digital Electronics 66


Dr. Mayank Thacker
Overflow in binary arithmetic
• Considering 2s complement method
• Ex – Add two numbers using 2s complement
0 1 0
(−6)10 1 0 1 0
+ (−5)10 +1 0 1 1
− 1110 1 0 1 0 1

Overflow
• For the 2s complement method, we discard the carry. It would
make the result positive, which will be an incorrect result.

ECL 102 – Digital Electronics 67


Dr. Mayank Thacker
Self-study / Homework
• Hexadecimal number addition and subtraction
• Octal number addition and subtraction
• 1s complement addition

ECL 102 – Digital Electronics 68 Finished 21-01-2025


Dr. Mayank Thacker

You might also like