Modulo Calculator
Calculate the remainder after division, including the quotient and a negative-number-correct result.
Last updated · View algorithm, constants and default inputs (JSON)
About this calculator
Remainder depends on the division convention: this tool shows the truncating remainder and the non-negative Euclidean modulo. Division by zero is undefined and returns an input error.
Worked example
calculated with the default values below
Dividend 27 · Divisor 5 Remainder 2.0000 · Quotient 5.0000 · Euclidean modulo 2.0000 · Divisible exactly No
General background references
Disclaimer
These calculators give general mathematical results. They suit study, planning and estimation — verify anything that feeds a graded submission, a published figure or a financial commitment.
Implementation source
This record describes the implementation used by this page. It is not independent validation. External references, when available, support only the stated formula or definition; estimates and custom rules retain their own assumptions.
Formula and variables
q = trunc(a ÷ b); r = a − qb; r_E = ((a mod b) + |b|) mod |b|
- q
- truncated quotient
- r
- remainder (sign of a)
- r_E
- non-negative Euclidean remainder
- a
- dividend
- b
- divisor
Inputs must be integers and the divisor must be nonzero. The truncating remainder can be negative; Euclidean modulo is normalized to a non-negative result.
Frequently asked questions
Why is the Euclidean modulo positive when my remainder is negative?
The remainder uses Math.trunc of a over b, which rounds toward zero, so negative 27 modulo 5 gives negative 2 because the quotient is negative 5. The Euclidean modulo instead forces a non-negative result with parentheses a percent b plus absolute b close parentheses modulo absolute b, returning 3 for the same input. The Divisible exactly check keys off the trunc remainder being zero, so negative 25 shows Yes while negative 27 shows No even though both sit within 5 of a multiple.