MATH CALCULATOR

Modulo Calculator

Enter an integer dividend and a positive integer modulus to find a nonnegative residue and its floor quotient.

Calculator

YOUR RESULTS
Nonnegative modulo result3
Floor quotient
-4

Page guide

Nonnegative modulo result and interpretation

The residue is at least zero and smaller than the modulus. Together with the floor quotient it satisfies dividend = quotient × modulus + residue, even for a negative dividend.

The formula

a = qm + r with q = floor(a/m) and 0 ≤ r < m.

Integer division supplies a remainder, then normalization selects the nonnegative representative. Supported inputs are safe integers, and the internal division uses integer arithmetic rather than a rounded decimal quotient.

Verified worked example

For −17 modulo 5, floor division gives quotient −4. Because −17 = (−4 × 5) + 3, the nonnegative modulo result is 3.

How to use this calculator

  1. Enter a whole integer dividend, which may be negative.
  2. Enter a positive whole modulus.
  3. Read the residue and floor quotient and check the displayed division identity in the method.

Modulo input conventions

Modulo describes membership in an integer residue class. With a positive modulus, every integer maps to one value from zero through one less than that modulus. This makes it useful for circular indexing and repeating cycles. A negative starting index wraps backward, yet its normalized result remains inside the nonnegative range.

Interpreting nonnegative modulo result

Programming languages differ in the sign convention used by their remainder operators. This calculator explicitly chooses floor division and a nonnegative residue. It validates safe input integers and performs the division with integer arithmetic, so large supported values do not acquire a rounding-induced residue. The quotient may be negative and is part of the displayed identity, not a truncated decimal approximation.

Assumptions & limitations

What this calculation assumes

  • The modulus is a positive integer and floor division selects a nonnegative residue.

What to keep in mind

  • Integer arithmetic only; fractional remainders and modular exponentiation are not included.

Common questions

Why is −17 modulo 5 not −2?

A signed remainder operator can return −2. Under the convention on this page, adding the positive modulus normalizes that remainder to 3.

Can the modulus be zero or negative?

No. This tool uses a strictly positive integer modulus. Zero does not define a division-based remainder, and negative-modulus conventions vary.

What does a modulo result of zero mean?

It means the dividend is an exact integer multiple of the modulus. For example, 20 modulo 5 is zero, with quotient 4.

Sources & further reading

Reviewed on