Swift 2.0 Study Notes (Day 13)-integer and floating-point data types, swift Study Notes
For Original Articles, please reprint them. Reprinted Please note: Guan Dongsheng's blog
Swift provides 8, 16, 32, and 64-Bit Signed and unsigned integers. These integer types follow the naming conventions of the C language. I have summarized the integer types in Swift:
Integer example:
Print ("UInt8 range: \ (UInt8.min )~ \ (UInt8.max )")
Print ("Int8 range: \ (Int8.min )~ \ (Int8.max )")
Print ("UInt range: \ (UInt. min )~ \ (UInt. max )")
Print ("UInt64 range: \ (UInt64.min )~ \ (UInt64.max )")
Print ("Int64 range: \ (Int64.min )~ \ (Int64.max )")
Print ("Int range: \ (Int. min )~ \ (Int. max )")
The output result is as follows:
UInt8 range: 0 ~ 255
Int8 range:-128 ~ 127
UInt range: 0 ~ 18446744073709551615
UInt64 range: 0 ~ 18446744073709551615
Int64 range:-9223372036854775808 ~ 9223372036854775807
Int range:-9223372036854775808 ~ 9223372036854775807
The above code calculates the range of each type through the min and max attributes of the integer.
The floating point type is mainly used to store decimal values or to store large integers. It can be divided into two types: float and double. The double-precision floating point uses more memory space than the floating point, and the value range and accuracy are relatively large.
Welcome to Guan Dongsheng Sina Weibo @ tony _ Guan Dongsheng.
Follow the public platform of Zhijie classroom to learn about the latest technical articles, books, and tutorials.
More boutique iOS, Cocos, mobile design courses please pay attention to the official site of Zhijie classroom: http://www.zhijieketang.com
Zhijie classroom Forum website: http://51work6.com/forum.php
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.