The Gateway to Computer Science Excellence
+7 votes

Consider $Z=X-Y$ where $X, Y$ and Z are all in sign-magnitude form. X and Y are each represented in $n$ bits. To avoid overflow, the representation of $Z$ would require a minimum of:

  1. $n$ bits
  2. $n-1$ bits
  3. $n+1$ bits
  4. $n+2$ bits
in Digital Logic by
edited by | 4k views

5 Answers

+26 votes
Best answer
Let $X$ and $Y$ represents $31$ and $- 31$ respectively in binary sign magnitude form. $X$ and $Y$ will take $6$ bits as range of sign magnitude form is $-\left(2^{(n-1)}-1\right)$ to $2^{(n-1)}-1$; where $n$ is the number of bits.

Now in question $Z= X-Y$,

$Z = 31 - (-31) = 62$

To represent $62$ in sign magnitude form we need $7\;( 6+1)$ bits.

Hence, $n+1$ bits needed.

Answer is $C$.
edited by
Overflow condition can be checked with MSb bit x’y’z or xyz’ so maybe n bits
As, 2's complement representation is in binary. So, we required one more bit to represent overflow.
Range of sign-magnitude form is not correct. it should be $\large (-2^{n-1}+1)\: to\: (+2^{n-1}-1).$
Fixed 👍

@Nitesh Singh 2

You're right. The range $-2^{n-1} \le X \le(2^{n-1}-1)$ is actually for 2's complement system of $n$-bit numbers. On the other hand, as for sign-magnitude form it's $-(2^{n-1}-1) \le X \le(2^{n-1}-1)$ including ($\pm 0$).

+9 votes
No overflow if two number with opposite sign are added.
Here $(X+(-Y))$ wont give any overflow if sign of $X$ and $-Y$ are opposite else it may cause overflow.
Nothing mentioned in question so in worst case it will give overflow.

Additional bit needed to handle overflow.
Total $n+1$ bits needed.
edited by
+3 votes

Overflow can occur when two same sign numbers are added or two opposite sign numbers are subtracted. For example:

let n = 4 bit, X = +6 and Y = -5 (1 bit for sign and 3 bit for magnitude)
Therefore, Z = X - Y = 6 - (-5) = 6+5 = 11
But result (Z) 11 needs 5 (= 4 + 1) bits to store, 
Sin integer 11 needs 1 bit for sign and 4 bit for magnitude. 

Therefore, to avoid overflow, the representation of Z would require a minimum of (n + 1)bits. Option (C) is correct.

+1 vote

ans (C)
+1 vote
N bits..

Who feel they will challenge please message me the email so that I can send links

Actually in sign magnitude addition and subtraction are 1 and 2's we can do subtraction using adder.but here we have 31-(-31) will get changed to problem of adder
by 1 flag:
✌ Low quality (Hira Thakur)

Related questions

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
52,345 questions
60,489 answers
95,297 users