ProgrammingVery hardGATE CS & IT · Infosys

What is printed?

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

Correct answer: B. True -0.0 True False

Positive and negative zero compare equal but print differently. 1e16 + 1 rounds back to 1e16 in double precision, while integer arithmetic keeps 2**53 + 1 exact.

More Python Programming questions

Exams that ask this topic