ProgrammingVery hardGATE CS · Product-company placement

What is printed?

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

Correct answer: A. False True True

9007199254740993 is 2**53 + 1, which is not representable as a double, so it rounds to 2**53. 2**53 + 3 is halfway between two doubles and rounds to the even neighbour 2**53 + 4.

More Python Programming questions

Exams that ask this topic