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:
You can look at examples of errors detected by the V3076 diagnostic. |