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

ROUNDDEC

ROUNDDEC returns the value of x rounded at a digit specified by n. The result has the mode, base, and scale of x.

Read syntax diagramSkip visual syntax diagram>>-ROUNDDEC(x,n)-----------------------------------------------><
 
x
Real expression that is either FIXED DECIMAL or DFP FLOAT. If x is negative, the absolute value is rounded and the sign is restored.
n
Optionally-signed integer. It specifies the digit at which rounding is to occur.

If x is FIXED DECIMAL or PICTURE FIXED DECIMAL, then ROUNDDEC produces the same results as ROUND.

If x is FLOAT DECIMAL or PICTURE FLOAT DECIMAL and the FLOAT(DFP) compiler is in effect, then ROUNDDEC rounds x at the nth decimal place rather than at the nth digit (as would the ROUND built-in function in accordance with the ANSI definition). For example, these successive roundings of 3141.592653589793d0 would produce the following values:

    dcl x float dec(16) init( 3141.592653589793d0 );

    display( fixed(rounddec(x,1),15,7) );  /* 3141.6000000 */
    display( fixed(rounddec(x,2),15,7) );  /* 3141.5900000 */
    display( fixed(rounddec(x,3),15,7) );  /* 3141.5930000 */
    display( fixed(rounddec(x,4),15,7) );  /* 3141.5927000 */
    display( fixed(rounddec(x,5),15,7) );  /* 3141.5926500 */
    display( fixed(rounddec(x,6),15,7) );  /* 3141.5926540 */
    display( fixed(rounddec(x,7),15,7) );  /* 3141.5926536 */

Terms of use | Feedback

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