I looked at the implementation of the
java.lang.Double class. The value of
NaN is the specified value of
public static final double NaN field is set to
0.0d / 0.0 which should evaluate to
0x7ff8000000000000L if the JVM does implement it that way.
Why was this value (
0x7ff8000000000000L) chosen? Is there anything special about that value (e.g. its bit mask)?
Why is the field implicitly set to that value and depends on the underlying implementation of the
0.0d / 0.0operation whereas the static method
public static long doubleToLongBits(double value)sets the value explicitly to
NaNargument? Wasn't it much safer to implicitly set it as the result of
0.0d / 0.0highly depends on the implementation of the JVM and could be changed (most likely it never will) theoretically?
The same goes for
NEGATIVE_INFINITY. Fields are implicitly set to their values but some methods use the explicit specified values. Is there a reason behind that?
Thanks for helping me to learn anything new each day :-).