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

ROUND of IEEE decimal floating point

The precision of an IEEE DECIMAL FLOAT result is the same as that of the source argument.

The value of the result is given by the following formula, where where b = 10 (=radix(x)) and e = exponent(x):

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

So, if the FLOAT(DFP) compiler option is in effect, these successive roundings of 3.1415926do would produce the following values:

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

    display( round(x,1) );  /* 3.000000000000000E+0000 */
    display( round(x,2) );  /* 3.100000000000000E+0000 */
    display( round(x,3) );  /* 3.140000000000000E+0000 */
    display( round(x,4) );  /* 3.142000000000000E+0000 */
    display( round(x,5) );  /* 3.141600000000000E+0000 */
    display( round(x,6) );  /* 3.141590000000000E+0000 */

Terms of use | Feedback

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