Learning Swift from scratch (day 13)--Integer and floating point type for data types

Source: Internet
Author: User

Original articles, welcome reprint. Reprint Please specify: Dongsheng's Blog

Swift provide 8 , - , + , - a signed and unsigned integer in bit form. These integer types follow the naming conventions of the C language, and I summarize the integral types in Swift :

650) this.width=650; "Width=" 550 "height=" "title=," image1.jpg "style=" width:550px;height:125px; "alt=" Wkiom1buc9qyzwb7aadsrr53mnu783.jpg "src=" http://s4.51cto.com/wyfs02/M01/7C/A2/ Wkiom1buc9qyzwb7aadsrr53mnu783.jpg "border=" 0 "vspace=" 0 "hspace=" 0 "/>

650) this.width=650; "Width=" 550 "height=" 127 "title=" image2.jpg "style=" WIDTH:550PX;HEIGHT:127PX; "alt=" wKiom1bUC__ Sneeiaad2-ltecde595.jpg "src=" http://s5.51cto.com/wyfs02/M00/7C/A2/wKiom1bUC__SNeEiAAD2-LteCdE595.jpg "border=" 0 "vspace=" 0 "hspace=" 0 "/>


Example of an integral type:

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 results are 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 is through an integer min and the Max Property calculates the range of each type.

floating-point types are primarily used to store decimal values, and can be used to store large integers. It is divided into floating-point (float) and double-precision floating-point (double), double-precision floating-point numbers use more memory space than floating-point number, can represent the range of values and precision is also relatively large.

650) this.width=650; "Width=" 550 "height=" + "title=" image3.jpg "style=" width:550px;height:71px; "alt=" WKioL1bUDKrw_ Nudaacvmm1lzkk201.jpg "src=" http://s3.51cto.com/wyfs02/M01/7C/A0/wKioL1bUDKrw_NuDAACVMm1Lzkk201.jpg "border=" 0 " Vspace= "0" hspace= "0"/>


Welcome to follow Dongsheng Sina Weibo@tony_Dongsheng.
Learn about the latest technical articles, books, tutorials and information on the public platform of the smart Jie classroom
650) this.width=650; "title=" 00.png "alt=" Wkiol1budmeypskcaaas2mbeznc891.png "src=" http://s2.51cto.com/wyfs02/M02/ 7c/a0/wkiol1budmeypskcaaas2mbeznc891.png "/>
More ProductsIOS,Cocos, mobile Design course please pay attention to the official website of Chi Jie Classroom:http://www.zhijieketang.com
Smart-Jie Classroom Forum Website:http://51work6.com/forum.php


This article is from the "Dongsheng-ios Technical Consultant" blog, make sure to keep this source http://tonyguan.blog.51cto.com/701759/1746103

Learning Swift from scratch (day 13)--Integer and floating point type for data types

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.