Division of integers in Java [duplicate]

Converting the output is too late; the calculation has already taken place in integer arithmetic. You need to convert the inputs to double:


Note that you don’t actually need to convert both of the inputs. So long as one of them is double, the other will be implicitly converted. But I prefer to do both, for symmetry.

Leave a Comment