MOD: Calculating the Remainder From a Division

How to:

MOD calculates the remainder from a division. The output data type is the same as the input data type.

Syntax: How to Calculate the Remainder From a Division

MOD(dividend, divisor)

where:

dividend

Numeric

Is the value to divide.

Note: The sign of the returned value will be the same as the sign of the dividend.

divisor

Numeric

Is the value to divide by.

If the divisor is zero (0), the dividend is returned.

Example: Calculating the Remainder From a Division

In the following request, MOD returns the remainder of PRICE_DOLLARS divided by DAYSDELAYED:

DEFINE FILE WFLITE
MOD1/D7.2= MOD(PRICE_DOLLARS, DAYSDELAYED);
END
TABLE FILE WFLITE
PRINT PRICE_DOLLARS/D7.2  DAYSDELAYED/I5 MOD1
WHERE DAYSDELAYED GT 1
ON TABLE SET PAGE NOPAGE
ON TABLE PCHOLD FORMAT WP
END

Partial output follows:

  Price     Days  
Dollars  Delayed      MOD1
-------  -------      ----
 399.00        3       .00
 489.99        3       .99
 786.50        2       .50
 599.99        4      3.99
  29.99        4      1.99
 169.00        2      1.00
 219.99        2      1.99
 280.00        3      1.00
  79.99        4      3.99
 145.99        2      1.99
 399.99        3       .99
 349.99        3      1.99
 169.00        3      1.00