File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
java/ql/src/Likely Bugs/Arithmetic Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -14,21 +14,21 @@ lowest 6 bits when the type is <code>long</code>.
1414<recommendation >
1515
1616<p >
17- Restrict the shift amount of <code >int</code >s to the range 0-31, or cast to <code >long</code > before left-shifting .
17+ Restrict the amount that you shift any <code >int</code > to the range 0-31, or cast it to <code >long</code > before applying the left shift .
1818</p >
1919
2020</recommendation >
2121<example >
2222<p >
23- The following line tries to left-shift an <code >int</code > 32 bits.
23+ The following line tries to left-shift an <code >int</code > by 32 bits.
2424</p >
2525
2626<sample src =" LShiftLargerThanTypeWidth.java" />
2727
2828<p >
29- However, left-shifting an <code >int</code > 32 bits is equivalent to
30- left-shifting 0 bits, that is, not shifting at all . Instead the value should
31- be cast to <code >long</code > before shifting to actually left-shift 32 bits.
29+ However, left-shifting an <code >int</code > by 32 bits is equivalent to
30+ left-shifting it by 0 bits, that is, no shift is applied . Instead the value should
31+ be cast to <code >long</code > before the shift is applied. Then the left-shift of 32 bits will work .
3232</p >
3333
3434<sample src =" LShiftLargerThanTypeWidthGood.java" />
You can’t perform that action at this time.
0 commit comments