in Digital Logic edited by
3,434 views
2 votes
2 votes

Consider a system that uses $5$ bits for representing signed integers in $2$ 's complement format. In this system, two integers $A$ and $B$ are represented as $A$=$01010$ and $B$=$11010$. Which one of the following operations will result in either an arithmetic overflow or an arithmetic underflow?

  1. $A+B$
  2. $A-B$
  3. $B-A$
  4. $2 * B$ 
in Digital Logic edited by
by
3.4k views

5 Answers

9 votes
9 votes
question is asked for 5 bits signed value
A is having 01010=10 in decimal
B is having 11010=-6 in decimal
Now A+B is 4 which is 00100, hence no overflow
Now A-B is 16 which is 010000, see that we used 6 bits hence it is overflow
Now B-A is -16 which is 10000, hence no overflow
Now 2*B is -12 which is 10100, hence no overflow

hence our correct option will be option B

2 Comments

This is the best approach written by @NeelParekh (by converting into decimal).

$\newline$

Another short & Intuitive approach:


A) We know, 2's complement addition overflow condition: $a_{n-1}b_{n-1}c_{n-1}^{'} + a_{n-1}^{'}b_{n-1}^{'}c_{n-1}$ i.e MSB of two no must be SAME. But here given two no's msb are diff, so no chance of Overflow. 

Ref: GATE CSE 2006 | Question: 39

D) $2*B ⇒ \underbrace{\boxed{11010} \ 0}_\text{arithmatic left shift}⇒ \underbrace{\cancel{1} \boxed{10100}}_\text{considering 5 bits} ⇒ \underbrace{01100}_\text{2's complement} ⇒ -12 \ (\text{within range}) $

So, no chance of Over or Underflow.

$\newline$

Now, as $A$ is a $+ve$ num & $B$ is $-ve$ num 

so, $B-A = -ve - (+ve) = -ve $

and $A - B = +ve - (-ve) = +ve $ 

So there is a chance of these 2 cases we may face $\text{arithmatic Overflow or Underflow }$ cz for these two cases the result may exceed the range.

$\newline$

Now by checking Option B and Option C we can get the ans easily :)

3
3
nice approach
0
0
2 votes
2 votes

 In 2 's complement system change use $2's$ $complement$ iff MSB is 1 else use plain binary 



 

4 Comments

🔥🔥

2
2

@AniMan_7 come online on telegram

0
0
online bulane ka tarika thoda czeual hai ):
0
0

@NeelParekh Gutley 

0
0
1 vote
1 vote

The range of signed 2's complement numbers with 5 bits is -16 to 15. Any operation that produces a result that is out of the bounds of this range will cause an overflow. given A = 10 (01010) and B = -6 (11010), by doing A - B the value equates to 16 which is out of the bound of the range that is supported by 5 bit numbers and hence causes overflow 

0 votes
0 votes

As we know the range of 2's complement number is $-2^{n-1} \text{ to } (2^{n-1} -1)$ because the given data is five-bit long so its range is $-16 $ to $+15.$ 

First calculate the value of $A, B$.

  • $A=01010=+10$ as the MSB bit is zero so the number is positive.
  • $B=11010=-2+4-8=-6$ as MSB bit is one so the number is negative.

Option A) $A+B= +10+(-6)=+4$

Option B) $A-B= +10-(-6)=+16$.To represent $(+16)_{10}\rightarrow (010000)_2$ it required total of six bits which is clearly out of range.

Option C) $B-A=-6-(+10)=-16$

Option D) $2*B=2*(-6)=-12$

So Option $(B)$ is correct.

Answer:

Related questions