Files
openide/java/java-impl/resources/inspectionDescriptions/SuspiciousIntegerDivAssignment.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

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>