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

The Gateway to Computer Science Excellence

+1 vote

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?

1) 101011 + 110101

2) 011111 + 000001

And also explain some concept about overflow?

0

convert them into decimal and perform addition

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

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

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 **C _{n-1} xor C_{n}=1 **where C

+4 votes

Note that numbers are represented in 2's complement form. therefore a_{n-1}, b_{n-1 }and s_{n-1 }are sign bits

1) a_{n-1} .............. a_{3 } a_{2 } a_{1 } a_{0}

2) b_{n-1} .............. b_{3 } b_{2 } b_{1 } b_{0}

c_{n} c_{n-1} .............. c_{3 } c_{2 } c_{1 } c_{0}

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

3) s_{n-1} .............. s_{3 } s_{2 } s_{1 } s_{0}

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

i) c_{n}⊕c_{n-1}_{ }= 0 ===> No overflow otherwise there is overflow

ii) a'_{n-1 . } b'_{n-1 } s_{n-1 + } a_{n-1 } b_{n-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

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

S_{n} means it is C_{n} only, then A⊕ A =0 always,

moreover i didn't mention, C_{n}⊕S_{n }in my explaination

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

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

in that example, they renamed sum bits with carry bits

the question follows my second formula

ii) a'

_{n-1 . }b'_{n-1 }s_{n-1 + }a_{n-1 }b_{n-1 }s'_{n-1 }= 0 ===> No overflow otherwise there is overflow

C

_{in}⊕C_{out}=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 c _{n−1}c_{n−2}…c_{0}**

actually the sum is denoted by s_{n-1} s_{n-2}....s_{0}

My formula is a'_{n-1 . } b'_{n-1 } s_{n-1 + } a_{n-1 } b_{n-1 } s'_{n-1 }= 0 ===> No overflow

put in this formula, c_{n-1} instead of s_{n-1}

it results your answer...

**The sum is denoted by c _{n−1}c_{n−2}…c_{0}**

the option **c** given as c_{out}⊕c_{n−1}

actually the sum is denoted by s_{n-1} s_{n-2}....s_{0}

then option C evaluates as c_{out }⊕ S_{n−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**.

- All categories
- General Aptitude 1.9k
- Engineering Mathematics 7.5k
- Digital Logic 2.9k
- Programming and DS 4.9k
- Algorithms 4.4k
- Theory of Computation 6.2k
- Compiler Design 2.1k
- Databases 4.1k
- CO and Architecture 3.4k
- Computer Networks 4.2k
- Non GATE 1.4k
- Others 1.4k
- Admissions 595
- Exam Queries 573
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 18

50,737 questions

57,342 answers

198,452 comments

105,214 users