In the first case, you are performing int / int
which will result in a int
value. So, if your denominator is larger than the numerator, the result will be truncated to 0.
In the second case, you are evaluating a double/double
expression which will evaluate to a double
value, hence preserving the fractional and integer parts.