We use cookies.This website uses essential cookies to operate core features. With your consent, we also use analytics cookies to understand traffic and improve the service. For more details, see our .
Was this tool helpful to use?
Your feedback helps us make it better
Calculate the remainder of two numbers after division. A free online modulo calculator supporting both positive and negative integer modulo operations.
Quotient truncated towards zero; remainder has same sign as dividend.
Formulas
a mod n = a - q × n
Where q is the quotient and n is the divisor. Different modulo modes use different rounding rules, which may lead to different results.
| Modulo Mode | Remainder |
|---|---|
| Truncated (C / JS / Java %) | 2 |
| Floored (Python %) | 2 |
| Euclidean (Non-negative remainder) | 2 |
Overview
Understand what the tool solves, how it works, and the boundaries of its data.
For dividend a and nonzero divisor b, a quotient q and remainder r satisfy a = q × b + r. With positive whole-number inputs the usual remainder is unambiguous. With negative values, conventions differ because they round the quotient differently. This calculator lets you select truncation, floor, or Euclidean remainder and shows the quotient alongside the result.
Truncated: q = trunc(a ÷ b); r = a − q × b. The remainder follows the dividend’s sign.
Floored: q = floor(a ÷ b); r = a − q × b. The remainder follows the divisor’s sign.
Euclidean: r is nonnegative and less than |b|; q is chosen so a = q × b + r.
For −17 divided by 5, truncation gives q = −3 and r = −2. Floor and Euclidean conventions give q = −4 and r = 3. The equation checks in both cases: −17 = (−3 × 5) + (−2), and −17 = (−4 × 5) + 3. In JavaScript, the percent operator is a remainder operation whose result follows the dividend’s sign; other languages and mathematical definitions may use a different convention.
Convention reference
Guide
Follow the workflow and verify inputs and outputs with practical examples.
Use signed integers or decimal numbers in ordinary decimal notation. The divisor must not be zero; incomplete or malformed entries do not produce a result.
Choose truncated, floored, or Euclidean. If matching a programming language or class exercise, follow its stated rule, especially when either input is negative.
Read the selected quotient and remainder, then verify that dividend = quotient × divisor + remainder. The comparison values let you see how another convention would handle the same inputs.
For example, enter −17 and 5. The truncated result is −2; the floored and Euclidean results are 3. Changing either number or the convention recalculates the displayed result.
Use cases
See how the tool fits into real work and everyday tasks.
When a worksheet includes negative division, select the convention used in the lesson and check both q and r in the division identity.
When debugging a remainder expression, compare a negative test case such as −17 and 5 with the target language’s documented rule before copying a result into code.
When mapping values to a repeating cycle, use a nonnegative remainder only if that is what the algorithm requires; test negative inputs at the boundary.
Q&A
Find concise answers to common questions and confusing cases.
The quotient rule changes. Truncation rounds −3.4 toward zero, giving −3 and remainder −2; floor rounds down to −4, giving remainder 3. Euclidean mode requires a nonnegative remainder and also gives 3 here.
Yes. Decimal entries are calculated with finite-precision floating-point arithmetic and formatted for display, so a long decimal result may be rounded. Whole-number inputs use exact integer arithmetic.
The operation is undefined for a zero divisor, so the calculator reports an input error instead of a quotient and remainder.
Notes
Review scope, result limitations, and important precautions before use.
“Modulo” and “remainder” are used differently across mathematical contexts and programming languages. Confirm the convention expected by your course, specification, or runtime before using a negative-input result. Decimal calculations are not arbitrary-precision results; do not use the formatted display as high-precision financial, scientific, or engineering output.
Related
Discover related tools, collections, and available API capabilities.