Which of the following rounding mode is followed by casting a double to an int?
It simply truncates towards zero - is represented by the confusingly-named DOWN
in your question.
From section 5.1.3 of the JLS:
A narrowing conversion of a floating-point number to an integral type T takes two steps:
In the first step, the floating-point number is converted either to a
long
, ifT
is long, or to anint
, ifT
isbyte
,short
,char
, orint
, as follows:
If the floating-point number is NaN (§4.2.3), the result of the first step of the conversion is an int or long 0.
Otherwise, if the floating-point number is not an infinity, the floating-point value is rounded to an integer value V, rounding toward zero using IEEE 754 round-toward-zero mode (§4.2.3). Then there are two cases:
[ ... ]
(The rest isn't relevant to the question.)