Because -1
and 9
are integers, so -1/9
is an integer division (with the result 0
, which when cast to double is 0.0
).
To do a floating point division, you should convert one of the numbers to double, (double) 9
, 9d
or simply 9.0
.
In the latter case, fraction
is already double (-1.0
) so fraction/9
is a floating point division.