Returns the modulus (remainder) of one number divided by another.

Syntax

MOD(<dividend expN>, <divisor expN>)

<dividend expN>

The number to be divided.

<divisor expN>

The number to divide by.

Description

MOD( ) divides <dividend expN> by <divisor expN> and returns the remainder. In other words, MOD(X,Y) returns the remainder of x/y.

The modulus formula is

<dividend>-INT(<dividend>/<divisor>)*<divisor>

where INT( ) truncates a number to its integer portion.

Note

Earlier versions of dBASE used FLOOR( ) instead of INT( ) in the modulus calculation. This change only affects the result if <dividend expN> and <divisor expN> are not the same sign, which in itself is an ambiguous case.

The % symbol is also used as the modulus operator. It performs the same function as MOD( ). For example, the following two expressions are identical:

mod( x, 2 )

x % 2