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

ROUND of FIXED

The precision of a FIXED result is:

  (max(1,min(p-q+1+n,N)),n)

Where (p,q) is the precision of x, and N is the maximum number of digits allowed. Hence, n specifies the scaling factor of the result.

n must conform to the limits of scaling-factors for FIXED data. If n is greater than 0, rounding occurs at the (n)th digit to the right of the point. If n is zero or negative, rounding occurs at the (1-n)th digit to the left of the point.

The value of the result is given by the following formula, where b = 2 if x is BINARY and b = 10 if x is DECIMAL:

round(x,n) = sign(x)*(b-n)* floor(abs(x)* (bn) + 1/2)

So, in the following example, the value 6.67 is output:

    dcl X fixed dec(5,4) init(6.6666);

    put skip list( round(X,2) );

Terms of use | Feedback

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