Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.8, 言語解説書

IEEE 10 進浮動小数点の ROUND

IEEE DECIMAL FLOAT の結果の精度は、ソースの引数の精度と同じです。

結果の値は、次の式によって得られます。ここで、b = 10 (=radix(x)) で、e = exponent(x) です。

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

したがって、FLOAT(DFP) コンパイラー・オプションが有効である場合、以下の連続した 3.1415926do の丸めにより、次の値が算出されます。

    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)