The Gateway to Computer Science Excellence
+1 vote
177 views
Which of the following results in overflow assuming numbers stored in 6-bit two's complement representation

1) 101011 + 110101

2) 011111 + 000001

And also explain some concept about overflow?
in CO and Architecture by (245 points) | 177 views
0
convert them into decimal and perform addition

if resultant decimal no, is in range of 6-bits, then no overflow, else overflow
0
1) It will be overflow because the decimal no after addition take 7 bit

2) No overflow because decimal after addition take 6 bit

But the ans given is 2
0

There are some situations when you add two +ve numbers(represented in 6 bits) and the resultant becomes -ve (represented in 6bits) AND when you add two -ve numbers they become +ve. Such cases are called overflow.

In 1) both the numbers( 101011 , 110101 ) are -ve as the numbers are represented in 2's complement form and the MSB of both are 1. When you add them it becomes 1 100000. The 7th bit has 1 but you have to ignore it because only 6 bits are given. So 100000 -> it is a -ve number. Obviously check if the result obtained is the actual sum or not. Addition of 2 -ve numbers give -ve result so no overflow.

2) 011111(+ve number) + 000001(+ve number) =  100000 which is a -ve number. So overflow.

Condition for checking overflow is Cn-1 xor Cn=1 where Cn is the last carryout bit.

0
updated as answer, you can check

3 Answers

+5 votes
Best answer

Overflow in second one

by Boss (35.7k points)
selected by
+4 votes

Note that numbers are represented in 2's complement form. therefore   an-1, bn-1 and sn-1 are sign bits

   1)    an-1 ..............  a a a a0

   2)    bn-1 ..............  b b b b0

     cn  cn-1 ..............  c c  c c0

---------------------------------------------

   3)    sn-1 ..............  s s s s0

 

Yes, there are two formulas for checking is it overflow or not?

i) cn⊕cn-1 = 0 ===> No overflow otherwise there is overflow

ii)   a'n-1 .   b'n-1   sn-1 +   an-1   bn-1   s'n-1  = 0 ===> No overflow otherwise there is overflow


Remembering these formulas easy But understanding the mechanism behind these points are somewhat tough but not impossible...

 

But as i commented

convert them into decimal and perform addition

if resultant decimal no, is in range of 6-bits, then no overflow, else overflow

those points you can easily understand.

1)  A = 1 0 1 0 1 1 ====> -32 +8+2+1 = -21

     B = 1 1 0 1 0 1 ====> -32+16+4+1 = -11

therefore A+B = -21-11=-32, what is the 2's complement range with 6 bits? -32 to +31 therefore no overflow

 

2)  A = 0 1 1 1 1 1 ====> 16+8+4+2+1 = 31

     B = 0 0 0 0 0 1 ====> 1 = 1

therefore A+B = 31+1=32, what is the 2's complement range with 6 bits? -32 to +31 therefore overflow

 

by Veteran (64.7k points)
0

@Saikh

chk it

$C_{n}\oplus C_{n-1}=1$ condition makes it overflow

but $C_{n-1}\oplus S_{n}=1$ this condition tells there is no overflow

then how 1st formula is correct?

0

Sn means it is Cn only, then A⊕ A =0 always,

moreover i didn't mention, Cn⊕Sn in my explaination

0
how $C_{n}$ and $S_{n}$ could be same :(

It should have different meaning
0
you are taking n bits ===> index starts from 0 ===> maximum n-1

when you do addition of two n bits ===> maximum n+1 bits in the result ===> maximum index is n

then What this index n represents?

it is sum bit or carry bit, you can give any name to it.

if you didn't understand it, 10 and 11 do addition, then see what is carry bit and sum bit at index n
0

Even this formula $C_{in}\oplus C_{out}=1$ doesnot guarantee overflow

right?

https://gateoverflow.in/1815/gate2006-39

0

in that example, they renamed sum bits with carry bits

the question follows my second formula

ii)   a'n-1 .   b'n-1   sn-1 +   an-1   bn-1   s'n-1  = 0 ===> No overflow otherwise there is overflow

 

Cin⊕Cout=1 does not guarantee overflow

all  my formulas and explanation which i mention in my answer, work in all condition

0

I cannot understand 

all  my formulas and explanation which i mention in my answer, work in all condition

but in 2006 gate question C) cannot be answer

right? 

+1

in that question

 

The sum is denoted by cn−1cn−2…c0

actually the sum is denoted by sn-1 sn-2....s0

My formula is  a'n-1 .   b'n-1   sn-1 +   an-1   bn-1   s'n-1  = 0 ===> No overflow

put in this formula, cn-1 instead of sn-1

it results your answer...


The sum is denoted by cn−1cn−2…c0

the option c given as cout⊕cn−1

actually the sum is denoted by sn-1 sn-2....s0

then option C evaluates as cout ⊕ Sn−1 which is wrong​​​​​​​

0 votes

i think you dont need to convert them to decimal all you need is binary sum these two numbers. 

and follow the formulae, 

1)if value of msb's of input is 00 and msb of sum is 1

or

2)if value of msb's of input is 11 and msb of sum is 0

than its a condition of overflow. and in second case we get

(101011)2 + (110101)2 = (100000)2 carry =1

(011111)2 + (000001)2 = (100000)2  carry =0

so second is  an overflow... (focus only on msb for overflow)

answer is 2.

 

 

by Boss (12.1k points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,644 questions
56,512 answers
195,560 comments
101,074 users