ProgrammingVery hardGATE CS · Product-company placement

What is printed?

What is printed?
a = 10 ** 16
print(float(a + 1) == float(a), int(float(2 ** 53 + 1)) - 2 ** 53, 2 ** 53 + 1.0 == 2 ** 53)
  1. A. True 0 True
  2. B. False 1 False
  3. C. True 1 True
  4. D. False 0 True

Correct answer: A. True 0 True

A float has a 53-bit significand, so integers above 2^53 are not all representable: 10^16 + 1 and 2^53 + 1 round to their even neighbours. Python ints themselves are exact; the loss happens on conversion to float.

More Python Programming questions

Exams that ask this topic