Possible Duplicate:
Comparing NaN values for equality in Javascript
Can anyone tell me why this is not working?
if(inbperr == NaN) { document.getElementById('inbclo').value = "N/A"; } else { document.getElementById('inbclo').value = "%" + inbperr; }
Instead of returning a percentage value, or "N/A", I want it to return "%NaN".
Check for NaN with self-equality In JavaScript, the best way to check for NaN is by checking for self-equality using either of the built-in equality operators, == or === . Because NaN is not equal to itself, NaN != NaN will always return true .
The math. isnan() method checks whether a value is NaN (Not a Number), or not. This method returns True if the specified value is a NaN, otherwise it returns False.
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).
NaN stands for Not A Number and is a common missing data representation. It is a special floating-point value and cannot be converted to any other type than float.
NaN
's are unusual: they are not equal to anything, even themselves. You need to use isNaN(inbperr)
to tell whether a value is a NaN or not.
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