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
?
In data science, Nan is used to represent the missing values in a dataset. So Nan is basically a placeholder to represent undefined or missing values. You can create the Nan value using float type. Since it is not a defined keyword in Python, you have to pass it to float in a string format (within quotes).
The Float. isNaN() method in Float Class is a built in method in Java returns true if this Float value or the specified float value is Not-a-Number (NaN), or false otherwise. Syntax: public boolean isNaN() or public static boolean isNaN(float val)
In Python, the float type has nan . nan stands for "not a number" and is defined by the IEEE 754 floating-point standard.
The Float object contains a static value, which is a float
type, called NaN
.
So
float myFloat = Float.NaN;
gives you what you are asking.
http://download.oracle.com/javase/6/docs/api/java/lang/Float.html#NaN
Sure! NaN is a static constant in the Float and Double classes.
double x = Double.NaN;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With