About this tool
Find the remainder and quotient of a division, and see how three common conventions differ when negative numbers are involved. This matters because % in JavaScript and C does not match % in Python or Excel's MOD(). Whole numbers of any size are computed exactly, and decimals work too.
How to use Modulo Calculator
- Enter the dividend a.
- Enter the divisor n.
- Compare the truncated, floored and Euclidean results.
Frequently asked questions
Why does −7 mod 3 give different answers in different languages?
Languages round the quotient differently. Truncating toward zero gives −1 (JavaScript, C), while flooring gives 2 (Python, Excel).
Which one is the mathematical modulo?
In number theory the result is usually taken between 0 and |n| − 1, which is the Euclidean convention.
Can the divisor be negative or a decimal?
Yes, both are supported. Only a divisor of 0 is rejected.