mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
35 lines
842 B
HTML
35 lines
842 B
HTML
<html>
|
|
<body>
|
|
Reports integer multiplications and left shifts that are implicitly cast to long.
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
void f(int i) {
|
|
long val = 65536 * i;
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied, the code changes to:</p>
|
|
<pre><code>
|
|
void x(int i) {
|
|
long val = 65536<b>L</b> * i;
|
|
}
|
|
</code></pre>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
void f(int i) {
|
|
long value = i << 24;
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied, the code changes to:</p>
|
|
<pre><code>
|
|
void f(int i) {
|
|
long value = (long) i << 24;
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<p>
|
|
Such multiplications are often a mistake, as overflow truncation may occur unexpectedly.
|
|
Converting an <code>int</code> literal to a <code>long</code> literal (<code>65536<b>L</b></code>) fixes the problem.
|
|
</p>
|
|
|
|
</body>
|
|
</html> |