Alex Rivera | Logout

Can float (or double) be set to NaN?

Asked 2011-09-14T15:50:59.500
25

Note: Similar to Can an integer be NaN in C++?

I understand this has little practical purpose, but can a float or double be set to NaN?

Edit
Report

1 Answer

12

Sure! NaN is a static constant in the Float and Double classes.

double x = Double.NaN;
answered 2011-09-14T15:54:28.693

Your Answer