Reputation: 2261
i want to let users edit a field with double data. I want to allow Double.NaN
(to void values). Is there a generic way (a predefined string) that is parsed to Double.NaN
from the method Double.valueOf(String)
without checking it in the background?
There is a special char looking like a diamond with a question mark in it (in HTML) that acts like NaN, but - well - the users wont find that on their keys.
Upvotes: 10
Views: 11653
Reputation: 308041
parseDouble("NaN")
will return a NaN
value:
System.out.println(Double.isNaN(Double.parseDouble("NaN"));
Upvotes: 3
Reputation: 612993
You can pass +NaN
or -NaN
or NaN
to valueOf()
and have it return a NaN. The documentation gives the full details.
Upvotes: 13