A floating-point value to convert to an integer. source
must be representable in this type after rounding toward zero.
整数へと変換する浮動小数点値.source
は、ゼロへの丸め後にこの型において表現可能でなければなりません。
Initializer
init(_:)
Creates an integer from the given floating-point value, rounding toward zero.
与えられた浮動小数点値から整数を作成します、ゼロへの丸めを行います。
Availability
- macOS 10.10+
- Mac Catalyst 13.0+
- Xcode 6.1+
Technology
- Swift Standard Library Swift標準ライブラリ
Declaration 宣言
init(_ source: Float80
)
Parameters パラメータ
source
Discussion 解説
Any fractional part of the value passed as source
is removed, rounding the value toward zero.
source
として渡される値の小数部分は何であれ取り除かれます、値はゼロへと丸められます。
let x = Int(21.5)
// x == 21
let y = Int(-21.5)
// y == -21
If source
is outside the bounds of this type after rounding toward zero, a runtime error may occur.
source
がゼロへの丸め後にこの型の境界の外側ならば、実行時エラーが起こるかもしれません。
let z = UInt(-21.5)
// Error: ...the result would be less than UInt.min