Fix cast to double moved outside division
At some point this code was changed from double/int division to double(int/int) division. This patch changes it back to double/int, implicitly making both the dividend and the divisor doubles.
At some point this code was changed from double/int division to double(int/int) division. This patch changes it back to double/int, implicitly making both the dividend and the divisor doubles.