4D v14.3

Mod

Home

 
4D v14.3
Mod

Mod 


 

Mod ( number1 ; number2 ) -> Function result 
Parameter Type   Description
number1  Longint in Number to divide
number2  Longint in Number to divide by
Function result  Real in Returns the remainder

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

Notes:

  • 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.
  • Be careful when using Mod with real numbers of a large size (above 2^31) since, in this case, its operation may reach the limits of the calculation capacities of standard processors.

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.

Example  

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

 
PROPERTIES 

Product: 4D
Theme: Math
Number: 98

 
HISTORY 

Created: < 4D v6

 
SEE ALSO 

Numeric Operators

 
ARTICLE USAGE

4D Language Reference ( 4D v12.4)
4D Language Reference ( 4D v11 SQL Release 6)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)