Skip to content

GATE CS 2019 Q8 — Number Representations (Fixed and Floating Point)

Explain with AI

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

Choose one option
View worked solution

Answer: C

In an nn-bit sign-magnitude representation:

  • 11 bit is used for the sign.
  • n−1n-1 bits are used for the magnitude.

The maximum magnitude that can be represented is 2n−1−12^{n-1} - 1. Therefore, the range of values for XX and YY is:

−(2n−1−1)≤X,Y≤2n−1−1- (2^{n-1} - 1) \le X, Y \le 2^{n-1} - 1

To find the range of Z=X−YZ = X - Y:

  • Maximum value of ZZ: Occurs when XX is maximum and YY is minimum: Zmax=(2n−1−1)−(−(2n−1−1))=2(2n−1−1)=2n−2Z_{\text{max}} = (2^{n-1} - 1) - (-(2^{n-1} - 1)) = 2(2^{n-1} - 1) = 2^n - 2
  • Minimum value of ZZ: Occurs when XX is minimum and YY is maximum: Zmin=−(2n−1−1)−(2n−1−1)=−2n+2Z_{\text{min}} = -(2^{n-1} - 1) - (2^{n-1} - 1) = -2^n + 2

Thus, the maximum magnitude of ZZ that needs to be represented is 2n−22^n - 2.

Let kk be the number of bits required to represent ZZ in sign-magnitude form. The maximum magnitude representable with kk bits is 2k−1−12^{k-1} - 1. To avoid overflow, we must satisfy:

2k−1−1≥2n−2  ⟹  2k−1≥2n−12^{k-1} - 1 \ge 2^n - 2 \implies 2^{k-1} \ge 2^n - 1

For any integer n≥1n \ge 1, the smallest integer kk that satisfies this inequality is:

k=n+1k = n + 1

Example:

Let n=3n = 3. The range of XX and YY is [−3,3][-3, 3].

The range of Z=X−YZ = X - Y is [−6,6][-6, 6].

To represent the magnitude 66 in binary, we need 33 bits (1102110_2). Adding 11 sign bit, we require a minimum of 44 bits, which is n+1n+1 bits.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Number Representations (Fixed and Floating Point) questions