Runs locally
Modulo
Non-negative remainder, including negatives.
Ctrl+Enter runs. Ctrl+Shift+Backspace clears.
Export and import are available after you sign in. Sign in
Non-negative remainder, including negatives. Runs in the browser. Nothing is uploaded.
About this tool
Find the remainder when A is divided by B. Unlike the % operator in many programming languages, the result is always non-negative, so −7 mod 3 gives 2.
How to use it
- 01
Enter the dividend A.
- 02
Enter the divisor B.
- 03
Read the remainder.
FAQ
Frequently asked questions
Why is −7 mod 3 equal to 2 here?
The tool returns the mathematical modulo, which is always between 0 and B − 1. Some languages return −1 for the same input.
Can B be zero?
No. Division by zero has no remainder, and the tool reports it as an error.