mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
31 lines
732 B
HTML
31 lines
732 B
HTML
<html>
|
|
<body>
|
|
Reports assignments whose right side is a division that shouldn't be truncated to integer.
|
|
<p>While occasionally intended, this construction is often buggy.</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
int x = 18;
|
|
x *= 3/2; // doesn't change x because of the integer division result
|
|
</code></pre>
|
|
<p>
|
|
This code should be replaced with:
|
|
<pre><code>
|
|
int x = 18;
|
|
x *= 3.0/2;
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
<p>
|
|
In the inspection options, you can disable warnings for suspicious but possibly correct divisions,
|
|
for example, when the dividend can't be calculated statically.
|
|
<pre><code>
|
|
void calc(int d) {
|
|
int x = 18;
|
|
x *= d/2;
|
|
}
|
|
</code></pre>
|
|
|
|
<p>
|
|
<small>New in 2019.2</small>
|
|
</p>
|
|
</body>
|
|
</html> |