ProgrammingVery hardJEE Advanced · CAT placement

What is printed?

What is printed?
import math
print(0.0 == -0.0, 1 / float('-inf'), 2 ** -1074 / 2 == 0, math.copysign(0.0, -1))
  1. A. True -0.0 False 0.0
  2. B. False 0.0 True -0.0
  3. C. True -0.0 True -0.0
  4. D. True 0.5 True -0.0

Correct answer: C. True -0.0 True -0.0

0.0 and -0.0 compare equal, and dividing a positive number by negative infinity gives -0.0. Halving the smallest subnormal rounds to zero, and copysign reads the sign bit of -0.0.

More Python Programming questions

Exams that ask this topic