The documentation for java.lang.Double.NaN says that it is
A constant holding a Not-a-Number (NaN) value of type
double. It is equivalent to the value returned byDouble.longBitsToDouble(0x7ff8000000000000L).
This seems to imply there are others. If so, how do I get hold of them, and can this be done portably?
To be clear, I would like to find the double values x such that
Double.doubleToRawLongBits(x) != Double.doubleToRawLongBits(Double.NaN)
and
Double.isNaN(x)
are both true.
You need
doubleToRawLongBitsrather thandoubleToLongBits.doubleToRawLongBitsextracts the actual binary representation.doubleToLongBitsdoesn’t, it converts allNaNs to the defaultNaNfirst.output: