GATE / CS ARCHIVE

GATE CSE 2000 / QUESTION 2.14

Floating-point loss of a small addend

Computer Organization & Architecture · Data Representation & Arithmetic · Full GATE CSE 2000 paper

GATE 2000, Q2.14 2 marks · MCQ
Report issue

Data Representation & Arithmetic

Question 2.14, GATE 2000: With 32-bit floating-point A=2·10^30,B=−2·10^30,C=1, perform X=A+B;Y=A+C;X=X+C;Y=Y+B. Choose(X,Y) from(1,1),(1,0),(0,1),(0,0).
Tap to enlarge
Your answer
Answer & solution

Answer: B under conventional single-precision rounding (no official key was published)

Step 1: Stored A and B are exact sign opposites, so A+B cancels to zero; subsequently X=0+1=1.

Step 2: Near magnitude 2·1030, single precision has a spacing vastly greater than 1. Thus A+1 rounds back to A, losing the small addend. Adding B afterward cancels to zero, giving Y=0.

Therefore B. This demonstrates nonassociativity of finite-precision addition. It assumes the stated 32-bit operations/rounding rather than an optimizer reassociating expressions or a wider intermediate format.

Original paper, page 5