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 rule is classified as:
You can look at examples of errors detected by the V3076 diagnostic. |
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders: