Modulo Operation in Java
Modulo Operation in Java
In Java, Math.floorDiv and Math.floorMod behave better than % and / , respectively, because the latter interpret the operations on negative numbers incorrectly.
Here is a small case:
1 | public class ModDemo { |
The output of the above code is:

While in Python, we do not have this issue:
