Yogesh Luthra Yogesh Luthra - 1 year ago 73
Java Question


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 double primitive a total order in Java?


< 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.