Swift's floating point number

Source: Internet
Author: User

A float is a number with a fractional part, which can represent a larger range than an integer type, and the stored value can be much larger or smaller than the value stored in an int type. Swift provides two signed floating-point number types:

A Double represents a 64-bit floating-point number. Used to represent a value that must be very large or high precision when high accuracy.

Float represents a 32-bit floating-point number. When used to represent a value that does not require 64-bit precision, the precision is smaller than double.

Note: Double has a minimum of 15 decimal digits, whereas float has only 6 decimal digits, and choosing that type in your code depends on the nature and size of the value you need. For example, the bank system of money flow related data needs high precision large range of values to represent, then you need to use double.

Swift's floating point number

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.