GATE Computer ScienceHardGATE CS (PYQ pattern)

In C with IEEE 754 single-precision float, let x = 16777216.0f (2²⁴). What are the values of (x + 1.0f) + 1.0f and x + (1.0f + 1.0f)?

  1. A. 16777218 and 16777218
  2. B. 16777216 and 16777216
  3. C. 16777216 and 16777218
  4. D. 16777217 and 16777218

Correct answer: C. 16777216 and 16777218

Above 2²⁴ the spacing between floats is 2. x + 1 is a tie and rounds to even, which is x again; adding 1 once more gives x again. But 1 + 1 = 2 is exact, and x + 2 = 16777218 is representable. Floating point addition is not associative.

More Digital Logic questions

Exams that ask this topic