Skip to main content
Previous sectionNext section

REM

Remainder after integer division of two values.

Synopsis

REM(numstr1,numstr2)

Arguments

numstr1 The dividend. An expression that resolves to a number or numeric string.
numstr2 The divisor. An expression that resolves to a non-zero number or numeric string.

Description

The REM function divides the value of numstr1 by numstr2, and returns the remainder following integer division (modulo) that results from this division. If a numstr value is the null string or a non-numeric value, REM parses its value as 0 (zero).

You cannot divide a number by 0. Attempting to do so results in a <DIVIDE> error.

The MOD function is functionally identical to the REM function. You can use the MODS function to perform modulo division on the elements of a dynamic array.

Note:

Caché MVBasic contains both a REM (remarks) statement and a REM (remainder) function. These are completely unrelated and should not be confused.

Examples

The following examples use the REM function to return the remainder value for an integer division operation:

PRINT REM(10,5);   ! returns 0
PRINT REM(10,4);   ! returns 2
PRINT REM(10,3);   ! returns 1
PRINT REM(10,6);   ! returns 4
PRINT REM(10,-6);  ! returns 4
PRINT REM(10,11);  ! returns 10
Copy code to clipboard

See Also