Casting and rounding

A cast converts on purpose, and (int) cuts off the fraction instead of rounding, so rounding a positive double means adding 0.5 before the cast, while an int widens to a double by itself.

From AP Computer Science A.