Swift Tutorial: Introduction 06 - Variables: Floats and Doubles

Written by Paul Napier on . Posted in Swift Tutorials: Introduction

Hello everyone and welcome to the sixth lesson in swift programming brought to you by MadApper. my name is Paul Napier and in this lesson we will cover another two of the basic types: floats and doubles.

In the last lesson we covered numbers which had nothing after the decimal place. However, if we are going to work with calculations, we are going to constantly face situations where we have decimal places. In these instances we will use either floats or doubles:

let myFloat: Float = 1.025
let myDouble: Double = 1.025

As a definition, floats are floating point numbers which has a 32 bit representation and can have a precision of only 6 decimal places. A double is a floating point number that has a 64 bit representation and a precision of at least 15 decimal places, so when you have large numbers and require a higher degree of accuracy, you should use a double. When declaring these floating point numbers implicitly, the compiler will choose the floating point number most suitable to your system.

So if I type:

let floatingPoint = 1.01

Then start typing floatingPoint again, I can see in the code assistant that the compiler has declared it as a Double. This is important to note and may cause you issues if you did not realise this later on in your code.

Ok, so we have covered off the basics of numbers. In the next lesson we are going to talk briefly about type safety and casting..


0 #3 boutique bio 2017-06-19 06:38
Many thanks, this website is really helpful.

talking to: -
relevant internet site: - sneak a peek at this web-site.: - click through the next
internet site: - he said: - [url= boutique bio:
0 #2 hypnose tabac lyon 2017-06-17 02:18
Thanks regarding delivering such substantial subject matter.

[url= - - -

Also visit my web blog hypnose tabac lyon:
0 #1 massage lyon 2017-05-26 21:24
Ma pauvre commune de Gigondas unissait pour moi aux simples beautes d'une nature vraiment
agreste l'attrait des souvenirs d'enfance, les traditions de bienfaisance, de bonne et saine popularite, leguees par mes chers parents.

my page; massage lyon:

Add comment

Security code