0% found this document useful (0 votes)
33 views20 pages

Lecture3 Chapter1 - Signed Numbers, Subtraction of Signed Numbers Using Complements

1) The document discusses different methods for representing signed binary numbers, including signed magnitude and signed complement representations. 2) It explains how to perform arithmetic addition and subtraction using the two's complement representation by taking the two's complement of the subtrahend and adding it to the minuend. 3) Examples of addition and subtraction in two's complement are provided to demonstrate how overflow is handled and how subtraction can be converted to addition by changing the sign of the number being subtracted.
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)
33 views20 pages

Lecture3 Chapter1 - Signed Numbers, Subtraction of Signed Numbers Using Complements

1) The document discusses different methods for representing signed binary numbers, including signed magnitude and signed complement representations. 2) It explains how to perform arithmetic addition and subtraction using the two's complement representation by taking the two's complement of the subtrahend and adding it to the minuend. 3) Examples of addition and subtraction in two's complement are provided to demonstrate how overflow is handled and how subtraction can be converted to addition by changing the sign of the number being subtracted.
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/ 20

Chapter1: Digital Systems and Binary

Numbers
Lecture3- Study Signed Numbers, Perform
Subtraction using Complements
Engr. Arshad Nazir, Asst Prof
Dept of Electrical Engineering
EE-223 Digital Logic Design Spring 2024 SEECS 1
Objectives
• Study Signed Numbers
• Perform Subtraction of Signed Numbers using
Complements

EE-223 Digital Logic Design Spring 2024 2


Signed Binary Numbers
• In ordinary arithmetic a negative number is indicated by minus sign and positive
number by plus sign. This is not possible in computers, because of hardware
limitations since computers must represent everything with binary digits. There
are two methods to do this:
➢ The signed magnitude convention uses the left-most bit to represent the sign
(0 for positive and 1 for negative).
➢ The signed complement system negates a number by taking its complement.
o It could be either, 1’s complement representation or 2’s complement
representation.

EE-223 Digital Logic Design Spring 2024 3


Representations of Negative
Numbers

MSB
Magnitude

Sign
Magnitude
0 denotes + MSB
1 denotes -

EE-223 Digital Logic Design Spring 2024 4


sign bit

Signed Magnitude 1 1 1 1 0 1 1 0
Negative

Convention 0 0 0 0 1 0 1 0 Positive

• The signed magnitude convention uses the left-most bit to represent the sign
(0 for positive and 1 for negative).
➢ The user determines whether the number is signed or unsigned
➢ If the binary number is signed, then the leftmost bit represents the sign
and the rest of the bits represent the number
➢ If the binary number is unsigned then the leftmost bit is the most
significant bit of the number
➢ For example:
o 01001 can be considered as 9 (unsigned binary) or a +9 because the left
most bit is zero.
o On the other hand, the string of bits 11001 represents binary
equivalent of 25 when considered as unsigned number or as –9 when
considered as signed number
EE-223 Digital Logic Design Spring 2024 5
Signed Complement System
• The Signed Complement System negative number is indicated by its
complement (Complement of positive number)
➢ Positive numbers always start with 0 (plus), its complement
(representing negative number) will always start with 1
➢ Signed complement system can use either 1’s complement or 2’s
complement.
➢ For example:
o +9 is represented only as 00001001 but –9 can be represented
as:
✓11110110 Signed 1’s complement representation
✓11110111 Signed 2’s complement representation

EE-223 Digital Logic Design Spring 2024 6


Number Representations
• The following is the representation for +11:
➢ 00001011
• The following are different methods for representing -11:
➢ Signed magnitude: 10001011
➢ Signed-1’s-complement: 11110100
➢ Signed-2’s-complement: 11110101

EE-223 Digital Logic Design Spring 2024 7


Signed Binary Numbers

0011
0100
0101
0110
0111

EE-223 Digital Logic Design Spring 2024 8


Arithmetic Addition (Signed-
Magnitude System)
• The addition of two signed binary numbers in the signed-magnitude
system follows the rules of ordinary arithmetic
• If the signs are the same, we add the two magnitudes and give the
sum the common sign
• If the signs are different, we subtract the smaller magnitude from the
larger and give the result the sign of the larger magnitude
• For example:
➢ -35+(-12)=-(35+12)=- 47
➢ -35+(+12)=-(35-12)=-23
➢ +35+(+12)=+(35+12)=+47
➢ +35+(-12)=+(35-12)=+23

EE-223 Digital Logic Design Spring 2024 9


Arithmetic Addition (Signed 2’s
Complement system)
• This system doesn’t require the comparison of the signs and the
magnitudes (as in signed-magnitude system), but only addition.
• The addition of two signed binary numbers with negative numbers
represented in signed-2’s complement form is obtained from
addition of the two numbers, including their sign bits.
• A carry out of the sign-bit position is discarded, provided there is no
over flow. Here the left-most bit of the result shows sign.
• If the sum is negative, it will always be in 2’s complement form.

EE-223 Digital Logic Design Spring 2024 10


2’s Complement Addition Rules

An overflow occurs since SUM≥ 2n-1

EE-223 Digital Logic Design Spring 2024 11


2’s Complement Addition Rules

An overflow occurs since SUM ˃2n-1

EE-223 Digital Logic Design Spring 2024 12


EE-223 Digital Logic Design Spring 2024 13
+64
+65
- 127

EE-223 Digital Logic Design Spring 2024 14


EE-223 Digital Logic Design Spring 2024 15
1’s Complement Addition Rules

–3
–4

Note: Case 1 and 2 are same for both complement methods


EE-223 Digital Logic Design Spring 2024 16
1’s Complement Addition Rules

EE-223 Digital Logic Design Spring 2024 17


Addition Examples

-31

(end carry discarded)

EE-223 Digital Logic Design Spring 2024 18


Arithmetic Subtraction
• Subtraction can be performed by simply converting the equation into an addition
formula.
➢ Take the 2’s complement of the subtrahend (including the sign bit) and add it to
the minuend (including the sign bit)
➢ A carry out of the sign bit position is discarded, Provided there is no overflow.
➢ Note: Subtraction operation can be changed to an addition operation if the sign
of the subtrahend is changed. This is easily done by taking it’s 2’s complement as
demonstrated in the following relationship
(±A) – (+B)= (±A)+(–B)
(±A) – (–B)= (±A)+(+B)
➢ For example (–6) – (–13) in binary
(11111010 –11110011)
=11111010+00001101=100000111
=00000111 (+7) Removing the end carry
EE-223 Digital Logic Design Spring 2024 19
The End

EE-223 Digital Logic Design Spring 2024 20

You might also like