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.
You can pass +NaN
or -NaN
or NaN
to valueOf()
and have it return a NaN. The documentation gives the full details.
parseDouble("NaN")
将返回NaN
值:
System.out.println(Double.isNaN(Double.parseDouble("NaN"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.