ProgrammingVery hardJEE Advanced · CAT placement

What is printed?

What is printed?
print(2**53 == float(2**53), 2**53 + 1 == float(2**53 + 1), 2**53 + 2 == float(2**53 + 2))
  1. A. True True True
  2. B. False False True
  3. C. True False False
  4. D. True False True

Correct answer: D. True False True

2**53 is exact in a double. 2**53 + 1 is not representable, so it rounds to 2**53 and the exact int comparison fails. 2**53 + 2 is representable and compares equal.

More Python Programming questions

Exams that ask this topic