Truncate a Decimal
Easyjava
Read a decimal number and print the result of casting it to int (the fractional part is dropped, moving toward zero).
Input: one decimal number (may be negative).
Output: one line — the value after (int) casting.
Example 1
Input
99.99
Output
99
Example 2
Input
-3.7
Output
-3
- -1000000000 <= number <= 1000000000
Hint 1
int i = (int) d; performs the narrowing cast.
Hint 2
Truncation drops the decimals; it does not round.
A double-to-int cast keeps only the whole-number part and discards everything after the decimal point, moving toward zero. That is why -3.7 becomes -3, not -4.