Вы находитесь на странице: 1из 13

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH
Name : A Rajeswara Rao
Designation : Head
Branch : Computer Engg
Institute : GMR Polytechnic, Karimnagar
Year/Semester : III Semester
Subject : Computer Architecture
Subject Code : CM-303
Topic : Information Representation,Arithmetic

operations
Duration : 50 Mts
Sub. Topic : Comparison of two fixed pointnumbers vide

sign and magnitude


CM303.24 1

Teaching Aids to be use : Animation clips & images


Objective

On completion of this period, we would able to know

• How to identify the signs of numbers as


identical
• How to compare the magnitudes A , B
• How to subtract two numbers using 2’s
complement method

CM303.24 2
Recap

In the previous class, we have learnt about:

• How fixed point addition/ subtraction can be


performed using signed magnitude
representation.

CM303.24 3
X-OR Operation
How to know that the signs of AR, BR are same
or different
It can be known by an X-OR operation between
the sign bits As, Bs
As Bs Y=As Bs
0 0 0
0 1 1
1 0 1
1 1 0

It can be observed that the result is 0 if the bits


are same and 1 if the bits are different
CM303.24 4
How to compare the magnitudes A and B

It can be known by a simple subtraction of


B from A using 2’s complement method.

CM303.24 5
Perform subtraction between A and B

Case1 : A>B

Let A=9 1001


B=4 0100
+5

1’s complement of B =1011


add 1 + 1
2’s complement of B = 1100

CM303.24 6
Perform subtraction between A and B
Contd..
Add 2’s complement of B to A
1001
1100
carry 1 0101 it is +5

As carry is generated result is positive +5

i.e,if carry is generated then it can be inferred that A>=B


CM303.24 7
Perform subtraction between A and B
Contd..
Case 2 : A<B
Let A=3 0011
B=5 0101
-2

1’s complement of B =1010


add 1 + 1
2’s complement of B = 1011

CM303.24 8
Perform subtraction between A and B
Contd..
Add 2’s complement of B to A
0011
1011
carry 0 1110

CM303.24 9
Perform subtraction between A and B
Contd..
It can be observed that carry is 0
Hence the result is negative and the magnitude
is 2’s complement of (1110)
1’s complement=0001
add 1 + 1
0010
The result is –0010 or -2

Hence it can be inferred that carry is 0 for the case A<B

CM303.24 10
Summary
In this class , you have learnt …

• How to identify that the signs of the operands


are same or not
• How to compare the magnitudes

• How to do subtraction using 2’s complement


method
CM303.24 11
Frequently asked questions

1. If A=1001 and B=0111 find A-B using 2’s


complement method

2. If A=0110 and B=1000 find A-B using 2’s


complement method

CM303.24 12
Quiz
1. After subtraction if the carry is 0, the following
operations have to be performed in 2’s
complement method

a) Complement the carry


b) Add 1 to the result
c) Complement the result
d) Complement the result and add1 to the result

CM303.24 13

Вам также может понравиться