V6038. Comparison with 'double.NaN' is meaningless. Use 'double.isNaN()' method instead.

The analyzer detected that a variable of type float or double is compared with a Float.NaN or Double.NaN value. As stated in the documentation (15.21.1), if two Double.NaN values are tested for equality by using the '==' operator, the result is false. So, no matter what value of 'double' type is compared with Double.NaN, the result is always false.

Consider the following example:

void Func(double d) {
  if (d == Double.NaN) {
    ....
  }
}

It's incorrect to test the value for NaN using operators '==' and '!= '. Instead, method Float.isNaN() or Double.isNaN() should be used. The fixed version of the code:

void Func(double d) {
  if (Double.isNaN(d)) {
    ....
  }
}

This diagnostic is classified as:


Bugs Found

Checked Projects
411
Collected Errors
14 123
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →
Accept