Mod

4D - Documentation   Français   English   German   4th Dimension 2003, Command Theme List   4th Dimension 2003, Command Alphabetical List   4th Dimension 2003, Constant Theme List   Back   Previous   Next

version 3


Mod (number1; number2) Number

ParameterTypeDescription
number1NumberNumber to divide
number2NumberNumber to divide by
Function resultNumberReturns the remainder

Description

The command Mod returns the remainder of the Integer division of number1 by number2.

Note: Mod accepts Integer, Long Integer, and Real expressions. However, if number1 or number2 are real numbers, the numbers are first rounded and then Mod is calculated.

You can also use the % operator to calculate the remainder (see Numeric Operators).

WARNING: The % operator returns valid results with Integer and Long Integer expressions. To calculate the modulo of real values, you must use the Mod command.

Examples

The following example illustrates how the Mod function works with different arguments. Each line assigns a number to the vlResult variable. The comments describe the results:

   vlResult:=Mod(3;2)  ` vlResult gets 1 
   vlResult:=Mod(4;2)  ` vlResult gets 0 
   vlResult:=Mod(3.5;2)  ` vlResult gets 0

See Also

Numeric Operators.


4D - Documentation   Français   English   German   4th Dimension 2003, Command Theme List   4th Dimension 2003, Command Alphabetical List   4th Dimension 2003, Constant Theme List   Back   Previous   Next