Modulo calculator

Type dividend a and divisor b, both non-negative. 17 and 5 give 2. 10 and 3 give 1. 8 and 4 give 0. 17.9 first drops to 17.

The fields have min=0, so the calculator is for non-negative values. The engine takes the remainder of the integer parts of a and b. When b = 0 the result is a blank value and the box stays blank.

Input data

Results

Enter data and click Calculate.

How it works

Modulo (remainder) asks how much is left after dividing a by b. 17 = 3 · 5 + 2, so 17 mod 5 is 2. The calculator first takes the integer part of both fields, then the % operator.

10 and 3 give 1, because 9 fits in 10 and 1 is left. 8 and 4 give 0: the division comes out clean. 17.9 and 5 also give 2, because 17.9 drops to 17 before it enters %.

Fields a and b have min=0. The browser keeps the input on non-negative numbers. This calculator does not compute a negative modulo. A comma in 17.9 still goes through floor.

When b = 0 the formula returns a blank value. The display clears the box on a blank value, so you see a blank, not the word a blank value and not zero. That is not a remainder of 0.

Floor is on the neighbouring page, because the same integer-part step cuts the fraction from a and from b. Signum does not divide. Here you always stay with a remainder of two non-negative floors.

17 and 5 give 2. 10 and 3 give 1. 8 and 4 give 0.

Formula

(b !== 0) ? (Math.floor(a) % Math.floor(b)) : a blank value

How to use

  1. Type a and b, for example 17 and 5. Both fields have min=0.
  2. Click Calculate. The remainder is 2.
  3. 10 and 3 give 1. 8 and 4 give 0.
  4. 17.9 first drops to 17, so with 5 you again get 2.
  5. b = 0 leaves the result box blank, because the formula returns a blank value.

17 and 5 give 2

a mod b after the integer part on both fields. 17 and 5 give 2. 10 and 3 give 1. 8 and 4 give 0. b = 0 leaves a blank.

modulo
The remainder. 17 and 5 give 2. 8 and 4 give 0. The fields are non-negative.
remainder
What is left after the quotient. 10 and 3 leave 1. b = 0 is not remainder 0, only a blank.
floor
Both sides go through the integer-part step. 17.9 becomes 17 before it enters %.

Examples

Example 1

  • a = 17
  • b = 5

2

What is 17 mod 5? 2. 15 fits in 17, 2 is left.

Example 2

  • a = 10
  • b = 3

1

What is 10 mod 3? 1. 9 fits in 10, 1 is left.

Example 3

  • a = 8
  • b = 4

0

What is 8 mod 4? 0. The division comes out clean.

Related calculators

Common questions

What is 17 mod 5?

2. 17 = 3 · 5 + 2. The result is 2.

What does modulo mean?

The remainder when a is divided by b. Here after the integer part on both fields. 10 and 3 give 1.

What are 10 mod 3 and 8 mod 4?

1 and 0. Zero means b divides a after floor.

What about 17.9 and 5?

2. Floor of 17.9 is 17, then 17 % 5 = 2.

What if b = 0?

The formula returns a blank value. The calculator clears the result, so you see a blank, not zero.

Does a negative a work?

The fields have min=0. This calculator is for non-negative values. You do not compute a negative % here.

How is this different from ordinary division?

Division returns the quotient. Here the remainder stays. 17 / 5 is 3.4. 17 mod 5 is 2.

Does a comma in 17.9 work?

Yes, and it still goes through floor. The result with 5 is 2.

Where is floor without a remainder?

On the floor page. Here floor is only the preparation for %.

Do 4 and 8 give 4?

Yes. 4 = 0 · 8 + 4, so the remainder is 4. The order of a and b matters.

Knowledge sources

The calculator computes the same formula as the definition below.

Page updated in 2026.