MOD

Return the remainder after dividing one number by another. The result has the sign of the divisor, as in Excel.

Syntax

MOD(number, divisor)
Argument Required Description
number Required The number to divide.
divisor Required The number to divide by. Zero returns #DIV/0!.

Examples

Every example below was executed against VisiGrid engine 0.54.0 — not transcribed from another vendor's documentation. Reproduce any of them with vgrid calc.

Formula Result Notes
=MOD(10,3) 1
=MOD(A2,2)=0 FALSE The standard even-number test. 7 is odd.
=MOD(-1,12) 11 The result takes the divisor's sign, so a negative offset wraps round a cycle.
=MOD(10,-3) -2
=MOD(5.5,2) 1.50 Works on fractions too.
=MOD(10,0) #DIV/0!

Even, odd, every Nth

MOD with a divisor of 2 is 0 for even numbers and 1 for odd ones. With ROW() it picks out every other row, or every Nth, for banding or sampling:

=MOD(ROW(),2)=0

Wrapping round a cycle

Because the remainder takes the sign of the divisor, MOD keeps a value inside a cycle even when it goes negative. Going back one month from January:

=MOD(1-1-1,12)+1  → 12

— December, not month 0 or -1. The same pattern wraps hours round a clock, angles round a circle and days round a week.

Some programming languages keep the sign of the dividend instead, so -1 % 12 is -1. Formulas moved between the two need checking wherever the first argument can be negative.

Splitting whole units from the rest

INT(n/d) gives how many whole times d fits in n, and MOD(n,d) gives what is left over — 130 minutes is INT(130/60) hours and MOD(130,60) minutes.

Excel compatibility

Matches Excel, including the sign of the result following the divisor.

Related functions

Last updated