Convert double to Int, rounded down
java, rounding, type-conversion
Solution
If you explicitly cast `double` to `int`, the decimal part will be truncated. For example:
int x = (int) 4.97542; //gives 4 only
int x = (int) 4.23544; //gives 4 only
Moreover, you may also use `Math.floor()` method to round values in case you want `double` value in return.
Problem
How to convert a `double` value to `int` doing the following: ``` Double If x = 4.97542. Convert to int x = 4. Double If x = 4.23544. Convert to int x = 4. ``` That is, the answer is always rounding down.