MOD()

Syntax. MOD(number,divisor)

Definition. This function returns the remainder of a division operation. The result has the same sign as the divisor.

Arguments

Background. For certain calculations, you need the remainder of a division operation. This is also called modulo (mod). For this type of calculation, you can use the MOD() function.

If the divisor is 0, the MOD() function returns the #DIV/0! error.

The MOD() function can be expressed in terms of the INT() function:

=numerator-divisor • INT(numerator/divisor)

This formula is used for the modulo method in software systems. There are two types of modulo calculations, which return different results for negative arguments:

Example. The MOD() function is often used together with other functions; for example, to add every second line (see Figure 16-20).

Adding every second line.

Figure 16-20. Adding every second line.

The formula is {=SUM(IF(MOD(ROW(C3:C8);2)=0;C3:C8;0))}. Because this is an array formula, you have to press Ctrl+Shift+Enter after you enter the formula.

More examples for this function are:

See Also

INT(), ROUND(), ROUNDDOWN(), ROUNDUP(), TRUNC()