Mathematics
Euclidean division and modulo
Divide an integer of up to 100 digits by a positive integer to get the quotient and a remainder that is never negative. For example, −7 divided by 3 gives quotient −3 and remainder 2.
Enter a whole-number dividend (up to 100 digits) and a positive whole-number divisor. Quotient and remainder are exact. You can change every value; the format of decimal results is under More options. Downloads keep your inputs and results, and nothing is saved or sent.
Result
Formula / calculation:
The calculator uses Euclidean division: a = b × q + r with 0 ≤ r < b. The remainder is never negative, even for a negative dividend; for example, −13 mod 5 is 2 with quotient −3. Numbers are handled exactly, up to 100 digits.
Decimal results are approximate. Inputs stay in this browser tab.
How it works
The formula and units appear with the result above. Decimal results are rounded for display; you can choose the format under More options.
About this calculation
The Euclidean division and modulo calculator splits an integer dividend by a positive integer divisor into a quotient and a non-negative remainder. It is useful for programming, number theory exercises and checking how negative numbers behave under the modulo operation.
The dividend a may contain up to 100 digits and the divisor b must be a positive integer. The result satisfies a = q × b + r with r at least 0 and smaller than b. With the default example a = -7 and b = 3, the quotient is -3 and the remainder is 2. An extra workflow compares floor division, where the remainder follows the divisor sign, with truncation towards zero, where it follows the dividend sign.
Integer results are exact. Inputs stay in the browser tab and exports are created only when you request them.
Worked example
With these example values the calculator gives the result below. You can change any value in the form above.
Inputs
- Integer dividend (up to 100 digits)
- -7
- Positive integer divisor
- 3
- Displayed decimal places (0–12)
- 6
- Result format
- Fixed decimals
Result
- Euclidean quotient
- -3
- Non-negative remainder
- 2
Frequently asked questions
How do I calculate the Euclidean quotient and remainder?
Enter an integer dividend a and a positive integer divisor b. The Euclidean division calculator finds q and r so that a = q × b + r, where the remainder r is non-negative and smaller than b.
What is -7 mod 3?
With Euclidean division, -7 divided by 3 gives a quotient of -3 and a non-negative remainder of 2, because -3 × 3 + 2 = -7.
How large can the numbers be?
The dividend may have up to 100 digits and the divisor must be a positive integer. In the additional floor and truncation workflow, both signed integers may have up to 100 decimal digits and the divisor must not be zero.
What is the difference between floor division and truncation?
Floor division rounds the quotient down, so a nonzero remainder takes the sign of the divisor. Truncation towards zero gives a nonzero remainder with the sign of the dividend. In both cases a = q × b + r holds and the remainder is smaller than |b|.
Are modulo results exact or rounded?
Integer division and modulo results are exact. Decimal values elsewhere are floating-point approximations, and you can set the displayed decimal places from 0 to 12.
Can I export modulo calculations?
Yes. Inputs and results can be downloaded as JSON, printable HTML, TXT or CSV, and up to 30 scenarios can be collected in the tab. Reloading the page clears the collection because nothing is stored.