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

ROUND of IBM hexadecimal floating point

The precision of an IBM hexadecimal floating point result is the same as that of the source argument.

Under the compiler option USAGE(ROUND(IBM)), the value of the result is the same as the source except on z/OS where if the source is not zero, then the result is obtained by turning on the rightmost bit in the source.

Under the compiler option USAGE(ROUND(ANS)), the value of the result is given by the following formula, where where b = 16 (=radix(x)) and e = exponent(x):

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

Note that under USAGE(ROUND(ANS)), the rounding is a base 16 rounding, and the results may not be what a naive user expects. For example, if compiled with USAGE(ROUND(ANS)) and IBM hexadecimal floating point instructions are used, these successive roundings of 3.1415926do would produce the following values:

    dcl x float bin(53) init( 3.1415926d0 );

    display( round(x,1) );  /*  3.000000000000000E+00  */
    display( round(x,2) );  /*  3.125000000000000E+00  */
    display( round(x,3) );  /*  3.140625000000000E+00  */
    display( round(x,4) );  /*  3.141601562500000E+00  */
    display( round(x,5) );  /*  3.141586303710938E+00  */
    display( round(x,6) );  /*  3.141592979431152E+00  */

Terms of use | Feedback

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