What’s the difference between Float.POSITIVE_INFINITY and Float.MAX_VALUE?
Which is greater?
Are they the same?
I came accross them looking for a value that would be greater than every other float or failing that all except the greatest. Does either meet that criteria?
Thanks!
No, they’re not the same thing at all.
Float.MAX_VALUEis the largest finite value that can be represented in afloat. You won’t find any value greater than that, other than infinity. But you can perform all kinds of other operations on it.Float.POSITIVE_INFINITYis, well, infinity. Most operations involving an infinity will end up with infinity (either positive or negative).For example:
Output: