Discussion 解説
This rounding rule is also known as “schoolbook rounding.” The following example shows the results of rounding numbers using this rule: この丸め規則はまた「教科書丸め」としても知られます。以下の例は、この規則を使っての数の丸めの結果を示します:
(5.2).rounded(.toNearestOrAwayFromZero)
// 5.0
(5.5).rounded(.toNearestOrAwayFromZero)
// 6.0
(-5.2).rounded(.toNearestOrAwayFromZero)
// -5.0
(-5.5).rounded(.toNearestOrAwayFromZero)
// -6.0
This rule is equivalent to the C round
function and implements the round
operation defined by the IEEE 754 specification.
この規則は、C round
関数の等価物です、そしてIEEE 754仕様によって定義されるround
演算を実装します。