O'Reilly logo

Mastering Swift 4 - Fourth Edition by Jon Hoffman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Floating-point and Double values

A floating-point number is a number with a decimal component. There are two standard floating-point types in Swift: Float and Double. The Float type represents a 32-bit floating-point number, while the Double type represents a 64-bit floating-point number. Swift also supports an extended floating-point type: Float80. The Float80 type is an 80-bit floating-point number.

It is recommended that we use the Double type over the Float type unless there is a specific reason to use the latter. The Double type has a precision of at least 15 decimal digits, while the Float type's precision can be as small as six decimal digits. Let's look at an example of how this can affect our application without us knowing it. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required