I just recently ran across the constants in the primitive type wrapper classes like Double.POSITIVE_INFINITY
and Double.NEGATIVE_INFINITY
. In the API, it defines the first as:
A constant holding the positive infinity of type double. It is equal to the value returned by Double.longBitsToDouble(0x7ff0000000000000L).
The others have definitions along these same lines.
What I'm having trouble with is understanding what these constants actually are. They can't actually be or represent positive/negative infinities, because the system is by nature finite. Is it just some arbitrary setting of bits which the Java creators deemed would define the concept of infinity? Or do these actually have some kind of special value? If it is just an arbitrary string of bits interpreted as a double
, then is there some normal number out there that, when interpreted as a double
will return POSITIVE_INFINITY
instead of whatever value is actually expected?
Forgive me if the answer to this is obvious given the Double.longBitsToDouble(0x7ff0000000000000L)
part of the API. Truthfully, that description is pretty arcane to me and I won't pretend to understand what the hexadecimal values actually mean or represent.