Skip to content
Official PYQ · 2000

GATE CS 2000 Q2.14 — Number Representations (Fixed and Floating Point)

Explain with AI

Consider the values of A=2.0×1030,B=−2.0×1030,C=1.0,A = 2.0 \times 10^{30}, B = -2.0 \times 10^{30}, C = 1.0, and the sequence 

   X:= A + B          Y:= A + C   
   X:= X + C          Y:= Y + B

executed on a computer where floating point numbers are represented with 3232 bits. The values for XX and YY will be

Choose one option
View worked solution

Answer: B

In a 32-bit single-precision floating-point representation (such as IEEE 754), the significand has 24 bits of precision, which offers approximately 7 decimal digits of precision.

For XX:

  1. X := A + B: Since AA and BB have equal magnitudes but opposite signs, they cancel out exactly: X=2.0×1030+(−2.0×1030)=0.0X = 2.0 \times 10^{30} + (-2.0 \times 10^{30}) = 0.0
  2. X := X + C: Adding CC gives: X=0.0+1.0=1.0X = 0.0 + 1.0 = 1.0

For YY:

  1. Y := A + C: We attempt to add 2.0×10302.0 \times 10^{30} and 1.01.0. Because their magnitudes differ by 30 orders of decimal magnitude (which vastly exceeds the 7-digit precision limit of 32-bit floats), the smaller value 1.01.0 is rounded off to zero during alignment. Thus: Y=2.0×1030+1.0≈2.0×1030Y = 2.0 \times 10^{30} + 1.0 \approx 2.0 \times 10^{30}
  2. Y := Y + B: Adding BB gives: Y=2.0×1030+(−2.0×1030)=0.0Y = 2.0 \times 10^{30} + (-2.0 \times 10^{30}) = 0.0

Therefore, the final values are X=1.0X = 1.0 and Y=0.0Y = 0.0, which corresponds to Option B.

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

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