# V3076. 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, if two double.NaN values are tested for equality by using the == operator, the result is false. So, no matter what value of type double 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:

CWE-570 CWE-571

You can look at examples of errors detected by the V3076 diagnostic.