GATE Computer ScienceVery hardGATE CS (PYQ pattern)

In IEEE 754 single precision with round-to-nearest-even (every operation rounded to single), which of these are true? I. 0.1f + 0.2f == 0.3f. II. (1.0e8f + 1.0f) − 1.0e8f == 0. III. 16777216.0f + 1.0f == 16777216.0f. IV. The double 0.1 equals the single 0.1f converted to double.

  1. A. II and III only
  2. B. III only
  3. C. I, II, III and IV
  4. D. I, II and III only

Correct answer: D. I, II and III only

III: 2²⁴ + 1 is a tie at spacing 2 and rounds to even, 2²⁴. II: near 10⁸ the spacing is 8, so 10⁸ + 1 rounds back to 10⁸ and the difference is 0. I: in single, 0.1f + 0.2f rounds to exactly the same float as 0.3f (unlike in double, where 0.1 + 0.2 ≠ 0.3). IV is false: 0.1f has only 24 significant bits, the double 0.1 has 53.

More Computer Organization and Architecture questions

Exams that ask this topic