hi, as far as i think comparing -0.0 ==0.0 always returns true. coz actually there is nothing like -0.0 and +0.0, both are just 0 and thus the equality test succeeds.
Regards<br />Sandy<br />[SCJP 5.0 - 75%]<br />[SCWCD 1.4 - 85%]<br />------------------<br />Tiger, Tiger burning bright,<br />Like a geek who works all night,<br />What new-fangled bit or byte,<br />Could ease the hacker's weary plight?
Actually for floating point numbers in Java, -0.0 and 0.0 are different. Math.min(-0.0,0.0) outputs -0.0, but -0.0 == 0.0 is true too..So it is a little wierd, but that is how it is. The floating point numbers (double and float) are in this order NEGATIVE_INFINITY --> negative integers/fractions --> -0.0 --> 0.0 --> positive integers/fractions --> POSITIVE_INFINITY This is what I know.
Originally posted by Roopesh Gulecha: ... The floating point numbers (double and float) are in this order NEGATIVE_INFINITY --> negative integers/fractions --> -0.0 --> 0.0 --> positive integers/fractions --> POSITIVE_INFINITY...
Well, the "order" of signed zeros depends on the context. Within the min and max methods of Math, this order exists. However, numerical comparison operators like > and < will not recognize an order.
It is mentioned in JLS that in Floating point numbers -0.0 and +0.0 are considered equal when "==" operator is used. Hence true is the answer. If any thing is to be changed in the answer for perfection, please let me know.