Previous Topic Next topic Print topic


MOD Function

Purpose

Returns the truncated remainder of x divided by y.

Syntax

MOD(x,y)

Parameters

x and y are arithmetic values.

Description

The MOD function returns the truncated remainder of x divided by y. The result is x-y*FLOOR(x/y) and has the common data type of x and y.

To determine the precision of the result, let (px,qx) and (py,qy) represent the precision of x and y, respectively. If the common type of x and y is fixed point, the precision of the result is:

(MIN(n,py-qy+MAX(qx,qy)),MAX(qx,qy))

Otherwise, the precision of the result is MAX(px,py). n is the maximum precision allowed for the common type of x and y. For details on maximum precisions, see your Open PL/I User's Guide.

Examples

MOD(15,2)    /* returns 1 */

Restrictions

The value of y must not be 0.

An MOD operation on floating-point decimal data is actually performed using the floating-point binary operation. Thus, the range of the operands and the result of the operation are limited to the ranges for floating-point binary numbers.

Previous Topic Next topic Print topic