我想了解如何访问Int的"struct"类型.当我cmd点击Int我带到了这个课程时,我想知道它可以容纳的最大值是多少.有没有办法从这个属性之一拉?这个结构中的最大值和最小值是多少?
struct Int : SignedInteger {
var value: Builtin.Word
init()
init(_ v: Builtin.Word)
init(_ value: Int)
static func convertFromIntegerLiteral(value: Int) -> Int
typealias ArrayBoundType = Int
func getArrayBoundValue() -> Int
static var max: Int { get }
static var min: Int { get }
}
Run Code Online (Sandbox Code Playgroud)
iPa*_*tel 63
"您可以使用其最小和最大属性访问每个整数类型的最小值和最大值:
let minValue = UInt8.min // minValue is equal to 0, and is of type UInt8
let maxValue = UInt8.max // maxValue is equal to 255, and is of type UInt8
Run Code Online (Sandbox Code Playgroud)
这些属性的值具有适当大小的数字类型(例如上面示例中的UInt8),因此可以在表达式中与其他相同类型的值一起使用."
摘录自:Apple Inc."The Swift Programming Language."iBooks.https://itun.es/in/jEUH0.
您可以使用min和max属性访问每个整数类型的最小值和最大值:
let minValue = UInt8.min // minValue is equal to 0, and is of type UInt8
let maxValue = UInt8.max // maxValue is equal to 255, and is of type UInt8
Run Code Online (Sandbox Code Playgroud)
这些属性的值具有适当大小的数字类型(例如上面示例中的UInt8),因此可以在表达式中与其他相同类型的值一起使用.
| 归档时间: |
|
| 查看次数: |
45540 次 |
| 最近记录: |