How do you set a double value to a "non-value"
Two obvious options:
- Use
Double
instead ofdouble
. You can then usenull
, but you've changed the memory patterns involved substantially. Use a "not a number" (NaN) value:
double d = 5.5; System.out.println(Double.isNaN(d)); // false d = Double.NaN; System.out.println(Double.isNaN(d)); // true
Note that some other operations on "normal" numbers could give you NaN values as well though (0 divided by 0 for example).

Author by
Admin
Updated on July 09, 2022Comments
-
Admin 28 days