Why is this an issue?
Certain mathematical comparisons will always return the same value, and should simply not be made.
These comparisons will return either always true
or always false
depending on the kind of comparison:
- Comparing a
char
with a numeric constant that is outside of the range of char
.
- Comparing a
float
with a numeric constant that is outside of the range of float
.
- Comparing a
long
with a numeric constant that is outside of the range of long
.
- Comparing a
ulong
with a numeric constant that is outside of the range of ulong
.
Noncompliant code example
float f = 42.0f;
if (f <= double.MaxValue) { } // Noncompliant