Mihsaba›Math›Modulo Calculator

Modulo Calculator

Calculate exact integer quotient and remainder, showing both programming-style remainder and Euclidean modulo for negative inputs.

Share this free calculator

Send this tool to someone who needs the calculation.

How to use

Remainder conventions can differ for negative integers. The calculator therefore shows both truncating programming-style remainder and non-negative Euclidean modulo.

  1. Enter integer dividend a and divisor b.
  2. The divisor must not be zero.
  3. Compare programming and Euclidean remainders and verify a=bq+r.

How it is calculated

a=bq+r; Euclidean remainder satisfies 0≤r<|b|

Example

17 mod 5 is 2 under both conventions. For −17 and 5, truncating remainder is −2 while Euclidean modulo is 3.

Important notes

Inputs are parsed as integer strings and computed with BigInt so integers larger than JavaScript’s safe-number range remain exact.

Worked examples and interpreting results

Dividing 17 by 5 gives integer quotient 3 and remainder 2. Negative inputs can produce different remainders under different conventions; the Euclidean remainder of −17 with divisor 5 is 3.

Worked examples and interpreting results
CaseCalculationResult
Remainder of 17 divided by 517 = 5 × 3 + 22
Euclidean remainder of −17 divided by 5−17 = 5 × (−4) + 33

How to check the result

Check dividend = divisor times quotient plus remainder. The Euclidean remainder is nonnegative and smaller than the divisor’s absolute value. Use integers and a nonzero divisor.

Frequently asked questions

What is the difference between modulo and remainder?

They usually agree for non-negative integers; negative operands expose the convention difference.

Does it support integers above 2^53?

Yes, integer arithmetic uses BigInt.

Can the divisor be zero?

No.

Why can negative remainders differ between tools?

Different conventions define division remainder when an operand is negative. Some programming languages follow the dividend’s sign while others return a non-negative modulo, so check the convention before comparing results.