A) prints -0.0, +0.0 and false. B) prints -0.0, +0.0 and true. C) prints 0.0, 0.0 and false. D) prints 0.0, 0.0 and true. The correct answer is A. How come System.out.println(Math.min(-0.0,+0.0) == Math.max(0.0,+0.0)) is true. I thought it is false because Math.min(-0.0,+0.0) is -0.0 and Math.max(0.0,+0.0)) is 0.0. Thanx in adv
Positive zero and negative zero compare equal; thus the result of the expression 0.0==-0.0 is true and the result of 0.0>-0.0 is false. But other operations can distinguish positive and negative zero; for example, 1.0/0.0 has the value positive infinity, while the value of 1.0/-0.0 is negative infinity. The operations Math.min and Math.max also distinguish positive zero and negative zero.