How this calculator works
Modulo depends on the remainder convention. Here the primary quotient is rounded toward negative infinity, so a non-zero remainder has the divisor's sign. The other two residues use a positive modulus |b|: one is non-negative and the other is non-positive. Decimal inputs are aligned as exact decimal integers before division.
Formula
q = floor(a/b); r = a - bq. For m = |b|, r_positive = a mod m in [0,m), and r_negative = r_positive - m unless the residue is zero.
Worked example
-7 modulo 3 is 2 because -7 = 3 × (-3) + 2. Its non-positive equivalent is -1. For 5.5 modulo 2, the remainder is 1.5.
Advertisement
Frequently asked questions
Why does a programming language give a different sign?
Some remainder operators truncate the quotient toward zero. For negative values that differs from the floor convention used here.
Are equivalent negative residues wrong?
No. Residues differing by a multiple of the modulus represent the same congruence class. The chosen interval determines the displayed representative.
Is modulo by zero defined?
No. There is no quotient-remainder calculation with a zero divisor.