TRUNC Function

Purpose

Returns the integer part of a specified value.

Syntax

TRUNC(x)

Parameters

x is an arithmetic expression.

Description

The TRUNC function returns the integer part of x. If x is floating-point, the precision of the result is the precision of x.

If x is fixed-point, the precision of the result is (MIN(n,MAX(p-q+1,1)),0). n is the maximum precision allowed for values of the result type. For details on maximum precisions, see your Open PL/I User's Guide.

For x < 0, the result is CEIL(x). For x ≥ 0, the result is FLOOR(x).

Examples

TRUNC(3.125)    /* returns 3 */
TRUNC(-3.125)   /* returns -3 */

Restrictions

None.