...
Integer type ranges are defined by the JLS, §4.2.1, "Integral Types and Values" [JLS 2005], and are also described in rule NUM00-J. Detect or prevent integer overflow.
The following table 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).
...
Note that conversions from float to double or from double to float can also lose information about the overall magnitude of the converted value. See rule NUM06-J. Use the strictfp modifier for floating-point calculation consistency across platforms for additional information.
Noncompliant Code Example (Integer Narrowing)
...
INT31-C. Ensure that integer conversions do not result in lost or misinterpreted data | ||||
| FLP34-C. Ensure that floating point conversions are within range of the new type | |||
INT31-CPP. Ensure that integer conversions do not result in lost or misinterpreted data | ||||
| FLP34-CPP. Ensure that floating point conversions are within range of the new type | |||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="37c3b12c144caf48-57d54591-4f514ffb-9be1b455-45024c2314b771d2061b55c2"><ac:plain-text-body><![CDATA[ | [ISO/IEC TR 24772:2010 | http://www.aitcnet.org/isai/] | Numeric Conversion Errors [FLC] | ]]></ac:plain-text-body></ac:structured-macro> |
CWE-681. Incorrect conversion between numeric types | ||||
| CWE-197. Numeric truncation error |
...