Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Function Index > M

MOD

Scroll Prev Top Next More

(MOD(arg1,arg2))

 

Computes a modulus or remainder of arg1 divided by arg2. Arg1 and arg2 must be values that have DOUBLE, REAL, NUMERIC, or INTEGER data types and arg2 cannot be 0.

 

In the following example, the value of vmod is 1, the remainder when 3 is divided by 2.

 

SET VAR vmod = (MOD(3,2))

 

In the following example, the value of vCheck4EvenOdd is checked if it is even or odd.

 

SET VAR vNumber2Check INTEGER = 3

SET VAR vCheck4EvenOdd INTEGER = (IFEQ((MOD(.vNumber2Check,2)),0,2,1))

IF vCheck4EvenOdd = 2 THEN

  PAUSE 2 USING 'The number is even.'

ELSE

  PAUSE 2 USING 'The number is odd.'

ENDIF