Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.8, Language Reference Manual

MOD

Example

MOD returns the smallest nonnegative value, R, such that:

  (x - R)/y = n

In this example, the value for n is an integer value. That is, R is the smallest nonnegative value that must be subtracted from x to make it divisible by y.

Read syntax diagramSkip visual syntax diagram>>-MOD(x,y)----------------------------------------------------><
 
x
Real expression.
y
Real expression. If y = 0, the ZERODIVIDE condition is raised.

The result, R, is real with the common base and scale of the arguments. If the result is floating-point, the precision is the greater of those of x and y. If the result is fixed-point, the precision is given by the following:

  (min(n,p2-q2+max(q1,q2)),max(q1,q2))

In this example, (p1,q1) and (p2,q2) are the precisions of x and y, respectively, and n is N for FIXED DECIMAL or M for FIXED BINARY.

If x and y are fixed-point with different scaling factors, the argument with the smaller scaling factor is converted to the larger scaling factor before R is calculated. If the conversion fails, the result is unpredictable.

The following example contrasts the MOD and REM built-in functions.

For information on the REM built-in function, see REM.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)