Reputation: 175
can we compare POSITIVE_INFINITY of Double wrapper in Java?
Basically what would be the result of comparison between double a and double b, where both are set as Double.POSITIVE_INFINITY?
A related question, is <= relation a total order on double primitive in Java?
Upvotes: 1
Views: 433
Reputation: 198033
<
and >
don't form a total order, but Double.compare
does.
Double.POSITIVE_INFINITY
compares as larger than anything but itself and Double.NaN
. If both are set as Double.POSITIVE_INFINITY
they will compare as equal.
Upvotes: 3