Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

GATE | GATE-CS-2000 | Question 37

  • Difficulty Level : Expert
  • Last Updated : 10 Oct, 2017

Consider the values A = 2.0 x 1030, B =-2.0 x 1030, 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 32 bits. The values for X and Y will be
(A) X = 1.0, Y = 1.0
(B) X = 1.0, Y = 0.0
(C) X = 0.0, Y = 1.0
(D) X = 0.0, Y = 0.0

Answer: (B)

Explanation: Given 32 bits representation. So, the maximum precision can be 32 bits.
Therefore, A + C should make the 31st digit to 1, which is surely outside the precision level of A (it is 31st digit and not 31st bit). So, this addition will just return the value of A which will be assigned to Y.
So, Y + B will return 0.0 while X + C will return 1.0.

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

Note that there is difference in 2000 and 2*10^3 representation. The result is depends on available number of digits for magnitude part. We can not adjust magnitude in exponent part.

So, option (B) is correct.

This explanation has been contributed by Piyush Doorwar.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :