Modulo Operations with Negative Numbers

Compare three modulo conventions for signed integers and see each quotient and remainder.

Result
—

How to calculate

Euclidean division uses a nonnegative remainder. Floored division rounds the quotient down. Truncated division rounds the quotient toward zero.

Worked example

Use Dividend -9 · Divisor 4 · Highlight convention Nonnegative remainder. The result is 3.

Input and result notes

Negative values are allowed. The divisor must be nonzero.

Kwong on modular arithmetic

Related calculators