您的位置:首页 > 移动开发 > Swift

Swift2.0基本数据类型汇总

2015-12-02 13:05 330 查看
There are a few other fundamental types as well:


Double. Similar to a
Float
but with more precision. You will use
Doubles later inthis tutorial for storing
latitude and longitude data. 双精度浮点型


Character. Holds just a single character.
A String
is a collection of
Characters. 字符型


UInt. A variation on
Int
that you may encounter occasionally. The U stands for “unsigned”, meaning
the type can hold positive values only. It’s called unsigned because it cannot have a negative sign (-) in front of the number.
UInt
can fit numbers between 0 and plus 4 billion but no negative numbers. On a 64-bit device, the upper limit of
UInt
is even higher, a little over 18 quintillion. 无符号整型,只能表示正数


Int8,
UInt8,
Int16,
UInt16,
Int32,
UInt32,
Int64,
UInt64. These are all variationson
Int. The difference is in how many bytes
they have available to store theirvalues. The more bytes, the bigger the values can be. In practice you almostalways use
Int, which uses 4 bytes for storage (a
fact that you may immediatelyforget) and can fit whole numbers ranging from minus 2 billion to plus 2 billion.On a 64-bit device,
Int
uses 8 bytes and can store positive and negative numbersup to about 19 decimal digits. Those are big numbers! 高位整型


CGFloat. This isn’t really a Swift type,
but a type defined by the iOS SDK. It’s adecimal point number like Float
and
Double. For historical reasons, this
is usedthroughout UIKit for floating-point values. (The “CG” prefix stands for the CoreGraphics framework.)  iOS SDK中特有的Float型
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: