Intermediate

Modulo Calculator

Compute the quotient and remainder of a ÷ b, with truncated, floored, and Euclidean modulo conventions for handling negative numbers.
Number being divided
Cannot be zero
Remainder (truncated)
2

Sign matches the dividend (JavaScript % operator)

Quotient (truncated)
3
Truncated remainder
2
Floored remainder
2
Euclidean remainder
2
00.61.31.92.53.13.84.45Euclidean remainder within [0, |b|)
Step by step
  1. 1

    Quotient (rounded toward zero)

    trunc(17 ÷ 5) = 3
  2. 2

    Truncated remainder

    17 − 5 × 3 = 2
    Sign follows the dividend — this matches the JavaScript % operator.
Results are estimates for general information only and are not professional advice — always verify important results independently before relying on them. Read the full disclaimer.
Quick answer

How does this calculator work?

The modulo of a ÷ b is the remainder left after division. With q = trunc(a/b), the truncated remainder is a − b·q (sign of a). Floored and Euclidean variants change the quotient rounding so the remainder follows the divisor or stays non-negative — important only when a or b is negative.

Formula
r = a − b × q, where q depends on the rounding convention (trunc / floor / Euclidean)
How this is calculated

Enter the dividend a (the number being divided) and the divisor b (the number you divide by). The divisor cannot be zero, since division by zero is undefined and the calculator returns no result in that case.

The quotient is q = trunc(a / b), rounding toward zero. The truncated remainder rT = a − b·q is what most programming languages (and the JavaScript % operator) produce: its sign follows the dividend a. The floored remainder rF = a − b·floor(a / b) follows the sign of the divisor b, which is the convention used by Python's % and modular arithmetic. The Euclidean remainder rE = a − b·floor(a / |b|) is always non-negative (0 ≤ rE < |b|), which is preferred in number theory.

For positive a and b all three remainders are identical. They differ only when a or b is negative. Inputs may be any real numbers — fractional values are allowed and the same formulas apply, though modulo is most commonly used with integers.

Frequently asked questions

They use different rounding rules for the quotient. Truncated rounds toward zero (C/JavaScript), floored rounds toward negative infinity (Python), and Euclidean always yields a non-negative remainder. For positive inputs they all agree.

Division by zero is undefined, so the calculator shows a warning and returns no result. Choose a non-zero divisor.

JavaScript, C, C++, Java and Go use the truncated remainder (sign of the dividend). Python and Ruby use the floored remainder (sign of the divisor).

Also known as

remainder calculator
mod calculator
modulus
mod operation
remainder of division

APA

TG we-Calculate Editorial Team. (2026). Modulo Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/modulo-calculator

Chicago

TG we-Calculate Editorial Team. "Modulo Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/modulo-calculator.

IEEE

TG we-Calculate Editorial Team, "Modulo Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/modulo-calculator

BibTeX

@misc{wecalculate_modulo_calculator, title = {Modulo Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/modulo-calculator}}, year = {2026}, note = {TG we-Calculate} }

Did this calculator help you?