...
Conversion from int
or long
to float
, or long
to double
can lead to loss of precision (loss of least significant bits). In this case, the resulting floating-point value is a rounded version of the integer value, using IEEE 754 round-to-nearest mode. Despite this loss of precision, the Java Language Specification requires that the conversion and rounding occur silently, that is, without any runtime exception. See the JLS, §5§5.1.2, "Widening Primitive Conversion" for more information.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="01ee372779c1917e-f50f8b9d-41d748d5-851e8984-62e4a13ed2665378e95106c0"><ac:plain-text-body><![CDATA[ | [[JLS 2005 | AA. Bibliography#JLS 05]] | [§5§5.1.2, "Widening Primitive Conversion" | http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.1.2] | ]]></ac:plain-text-body></ac:structured-macro> |
...
NUM16-J. Convert integers to floating point for floating-point operations 03. Numeric Types and Operations (NUM) NUM18NUM19-J. Be aware of numeric promotion behaviorEnsure that division and modulo operations do not result in divide-by-zero errors