...
Integer type ranges are defined by the Java Language Specification, Section 4.2.1, "Integral Types and Values" [JLS 2005] and are also described in NUM00-J. Ensure that integer operations do not result in Detect or prevent integer overflow.
The table below presents the rules for narrowing primitive conversions of integer types. In the table, for an integer type T
, n
represents the number of bits used to represent the resulting type T
(precision).
...
[Harold 1999]
[JLS 2005] Section 5.1.3, "Narrowing Primitive Conversions"
...
NUM00-J. Ensure that integer operations do not result in overflow 03. Integers (INT) NUM01-J. Do not assume that the remainder operator always returns a non-negative result for integral operands