Can I check for NaN ?
in
Programming Questions
•
1 year ago
Hello there!
I do some simple maths to calculate an average of some numbers.. and then print this average..
Some times instead of printing the average it prints "NaN" which is "Not A Number"..
Is there any way to check for this result in a similar way how I check for null?
Can I say something like this.. ?
if(average!= NaN){
do this
}else{
do that
}
EDIT: I see that in Java there is a function like isNaN() but it does not exist in Processing?
Any thoughts?
Thank you very much!
I do some simple maths to calculate an average of some numbers.. and then print this average..
Some times instead of printing the average it prints "NaN" which is "Not A Number"..
Is there any way to check for this result in a similar way how I check for null?
Can I say something like this.. ?
if(average!= NaN){
do this
}else{
do that
}
EDIT: I see that in Java there is a function like isNaN() but it does not exist in Processing?
Any thoughts?
Thank you very much!
1