VALUE1
mod
VALUE2

The mod operator computes the remainder (modulo) after integer division.


Parameters

This operator has two parameters:

value1 – The first numeric or text value.

value2 – The second numeric or text value.


Description

The mod operator converts both operands into integers and then divides them. It ignores the result of the division and calculates the remainder. The result is always an integer ranging from 0 to one less than the right hand operand.

16 mod 5 ☞ 1
17 mod 5 ☞ 2
18 mod 5 ☞ 3
19 mod 5 ☞ 4
20 mod 5 ☞ 0
21 mod 5 ☞ 1
22 mod 5 ☞ 2
23 mod 5 ☞ 3
24 mod 5 ☞ 4

As you can see, the mod operator can be used to generate a sequence of repeating numbers from 0 to a number you specify. For example, here is a quick formula that can be used to arbitrarily select every 4th record in a database.

seq() mod 4 = 0

Note for C Programmers: The mod operator is equivalent to C’s % operator.


Error Messages

Cannot modulo text by a number – Both parameters of the mod operator must be numbers.


See Also


History

VersionStatusNotes
10.0No ChangeCarried over from Panorama 6.0