Home › Math › Modulo Calculator
Modulo Calculator
Divides one number by another and reports the remainder under the three common sign conventions (truncated as in C/JavaScript, floored as in Python, and the non-negative Euclidean modulo) together with the integer quotient.
When to use
You need a mod b, the remainder of a division, or want to know how different programming languages treat negative operands.
Do not use when: You need the prime factors or divisors of a number (use prime-factorization) or a change of number base (use base-converter).
Formula
truncated: r = a − b·trunc(a/b); floored: r = a − b·⌊a/b⌋; Euclidean: r = a − |b|·⌊a/|b|⌋ (0 ≤ r < |b|)
Inputs
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
dividend | number | yes | The number being divided. Integers are exact; decimals are allowed. Range: ≥ -1000000000000000, ≤ 1000000000000000 | |
divisor | number | yes | The number to divide by; must not be 0. Range: ≥ -1000000000000000, ≤ 1000000000000000 |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
remainder | number | a − b × trunc(a / b): the % operator of C, Java and JavaScript. | |
quotient | number | trunc(a / b), rounded toward zero. | |
floored_modulo | number | a − b × ⌊a / b⌋: the % operator of Python and the mod of spreadsheets. | |
modulo | number | The mathematical residue in [0, |b|): a − |b| × ⌊a / |b|⌋. | |
is_divisible | boolean | true when the remainder is 0. | |
expression | string | a = b × quotient + remainder with the truncated convention. |
Example
17 mod 5: {"dividend":17,"divisor":5} → {"remainder":2,"quotient":3,"floored_modulo":2,"modulo":2,"is_divisible":false,"expression":"17 = 5 × 3 + 2"}
−7 mod 3: {"dividend":-7,"divisor":3} → {"remainder":-1,"quotient":-2,"floored_modulo":2,"modulo":2,"is_divisible":false}
GET https://tttkmbb.com/api/v1/calculate/modulo?dividend=17&divisor=5
Machine access
- API:
GET https://tttkmbb.com/api/v1/calculate/modulo(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/modulo · Markdown: https://tttkmbb.com/math/modulo.md · JSON definition: https://tttkmbb.com/math/modulo.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="modulo" - OpenAPI operationId:
calculate_modulo - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
- Wikipedia – Modulo (reference)
- Wikipedia – Euclidean division (reference)
- Wolfram MathWorld – Mod (reference)
FAQ
Why does −7 mod 3 give both −1 and 2?
Languages disagree on the sign: C, Java and JavaScript return −1 (remainder takes the sign of the dividend), Python and Excel return 2 (sign of the divisor). The Euclidean modulo is always non-negative.
Does it work with decimals?
Yes, e.g. 7.5 mod 2 = 1.5. Because inputs are binary floating-point numbers, results like 0.3 mod 0.1 may show tiny rounding artefacts.
Related calculators
- GCD and LCM Calculator — The Euclidean algorithm is built from repeated modulo.
- Number Base Converter — Base conversion uses repeated division with remainder.
- Day of the Week Calculator — Calendar arithmetic is modulo 7.