Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse String to Double.NaN

Tags:

java

string

nan

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.

like image 216
matcauthon Avatar asked May 25 '12 08:05

matcauthon


1 Answers

You can pass +NaN or -NaN or NaN to valueOf() and have it return a NaN. The documentation gives the full details.

like image 114
David Heffernan Avatar answered Oct 13 '22 18:10

David Heffernan