You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
will always return the same value, and should not be performed.</p>
4
+
<p>Specifically, the following comparisons will return either always <code>true</code> or always <code>false</code> depending on the kind of
5
+
comparison:</p>
4
6
<ul>
5
-
<li> Comparing a <code>char</code> with a numeric constant that is outside of the range of <code>char</code>. </li>
6
-
<li> Comparing a <code>float</code> with a numeric constant that is outside of the range of <code>float</code>. </li>
7
-
<li> Comparing a <code>long</code> with a numeric constant that is outside of the range of <code>long</code>. </li>
8
-
<li> Comparing a <code>ulong</code> with a numeric constant that is outside of the range of <code>ulong</code>. </li>
7
+
<li> comparing a <code>char</code> with a numeric constant that is outside of the range of <code>char</code></li>
8
+
<li> comparing a <code>float</code> with a numeric constant that is outside of the range of <code>float</code></li>
9
+
<li> comparing a <code>long</code> with a numeric constant that is outside of the range of <code>long</code></li>
10
+
<li> comparing a <code>ulong</code> with a numeric constant that is outside of the range of <code>ulong</code></li>
11
+
<li> etc. </li>
9
12
</ul>
10
13
<h3>Noncompliant code example</h3>
11
14
<pre>
12
15
float f = 42.0f;
13
-
if (f <= double.MaxValue) { } // Noncompliant
16
+
if (f <= double.MaxValue) { } // Noncompliant: always true
17
+
if (f > double.MaxValue) { } // Noncompliant: always false
14
18
</pre>
19
+
<h2>Resources</h2>
20
+
<h3>Documentation</h3>
21
+
<ul>
22
+
<li> Microsoft Learn: <ahref="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/comparison-operators">Comparison
23
+
operators (C# reference)</a></li>
24
+
<li> Microsoft Learn: <a
25
+
href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types#characteristics-of-the-integral-types">Ranges for integral numeric types (C# reference)</a></li>
26
+
<li> Microsoft Learn: <ahref="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/char">Range for char (C#
0 commit comments