...
The Java Language Specification (JLS) [JLS 2011], §5.6, "Numeric Promotions" [JLS 2011], " describes numeric promotion as the following:
...
Type coercion may occur when compound expressions are used with mixed operand types. Examples of compound assignment operators are +=, -=, *=, /=, &=, ^=, %=, <<=, >>=, >>>=, and |=.
According to the JLS, §15.26.2, "Compound Assignment Operators,"
...
Failing to consider integer promotions when dealing with floating-point and integer operands can result in loss of precision.
Bibliography
Puzzle 9, "Tweedledum" | |
"BIT: Bitwise OR of Signed Byte Value" | |
[JLS 2011] | §4.2.2, "Integer Operations" |
...