The integral value found by rounding using rule.ruleを使って丸められることによって見出される整数値。
Discussion
解説
The following example rounds a value using four different rounding rules:
以下の例はある値を4つの丸め規則を使って丸めます:
let x =6.5// Equivalent to the C 'round' function:print(x.rounded(.toNearestOrAwayFromZero))// Prints "7.0"// Equivalent to the C 'trunc' function:print(x.rounded(.towardZero))// Prints "6.0"// Equivalent to the C 'ceil' function:print(x.rounded(.up))// Prints "7.0"// Equivalent to the C 'floor' function:print(x.rounded(.down))// Prints "6.0"
For more information about the available rounding rules, see the FloatingPointRoundingRule enumeration. To round a value using the default “schoolbook rounding”, you can use the shorter rounded() method instead.
利用可能な丸め規則についてのさらなる情報として、FloatingPointRoundingRule列挙を見てください。省略時の「教科書丸め」を使って値を丸めるには、あなたはより短いrounded()メソッドを代わりに使うことができます。