Swift 2.0 Study Notes (Day 13)-integer and floating-point data types, swift Study Notes

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.