x のモード、基数、およびスケールを持ち、n で指定された桁で四捨五入の規則を適用して丸めた値を返します。
ROUNDAWAYFROMZERO(x,n)
dcl x float dec(16) init( 3141.592653589793d0 ); display( fixed(roundawayfromzero(x,1),15,7) ); /* 3141.6000000 */ display( fixed(roundawayfromzero(x,2),15,7) ); /* 3141.5900000 */ display( fixed(roundawayfromzero(x,3),15,7) ); /* 3141.5930000 */ display( fixed(roundawayfromzero(x,4),15,7) ); /* 3141.5927000 */ display( fixed(roundawayfromzero(x,5),15,7) ); /* 3141.5926500 */ display( fixed(roundawayfromzero(x,6),15,7) ); /* 3141.5926540 */ display( fixed(roundawayfromzero(x,7),15,7) ); /* 3141.5926536 */
dcl x float dec(16) init( 6022.140857 ); put skip list( roundawayfromzero(x,1) ); put skip list( roundawayfromzero(x,2) ); put skip list( roundawayfromzero(x,3) ); put skip list( roundawayfromzero(x,4) ); put skip list( roundawayfromzero(x,5) ); put skip list( roundawayfromzero(x,6) );
出力は次のようになります。
6.022100000000000E+0003 6.022140000000000E+0003 6.022141000000000E+0003 6.022140900000000E+0003 6.022140860000000E+0003 6.022140857000000E+0003
なし。
説明
ROUNDAWAYFROMZERO 関数は、指定された値 x を、指定された桁 n で四捨五入の規則を適用して丸めます。
x の値が FIXED DECIMAL または PICTURE FIXED DECIMAL の場合、ROUNDAWAYFROMZERO は ROUND 関数と同じ結果を返します。
x の値が FLOAT DECIMAL で、-dfp コンパイラ オプションが有効な場合、ROUNDAWAYFROMZERO は、n 桁目ではなく、n 桁目の小数位で x を丸めます。