Yogesh Luthra
Yogesh Luthra

Reputation: 175

POSITIVE_INFINITY comparison

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

Answers (1)

Louis Wasserman
Louis Wasserman

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

Related Questions