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:

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: Correct Answer n + 1 bits

No Overflow occurs if two number with opposite signs are added.

Overflow is possible only when two number with same signs are added.

Numbers are in sign-magnitude form

Therefore, X and Y can take any value between - (2(n - 1) - 1) to (2(n - 1) - 1)

Assume n = 4

Therefore, X and Y can take any value between -7 to 7

Z = X - Y

To make X and Y of same sign take X as negative or take Y as negative but do not take both simultaneously. Also take larger number to force overflow

Case I: X = -7 and Y = 7

Z = -7 - 7 = -14 // smallest number possible

Case II: X = 7 and Y = -7

Z = 7 - (-7) = 7 + 7 = 14 // largest number possible

Case I and Case II are extreme overflow conditions

Based on Assumption (4 bit) on sign-magnitude form

Range of n - 1 = 3 bit = -3 to 3

Range of n = 4 bit = -7 to 7

Range of n + 1 = 5 bit = -15 to 15 // capable of handling overflow

Range of n + 2 = 6 bit = -31 to 31 // capable of handling overflow

Minimum number of bit needed = 5 = n + 1

Related Questions