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 #8 Can a mean P. 2017-10-02 10:11
Are you looking for acadmic help?
don't worry we provided professional service of this.

visit here and tell us your work.
0 #7 The Word Point 2017-09-30 02:44
It has not till hell freezes over been easier to judge
between the interpretation services, as all consumer opinions and testimonials
are gathered in anyone see fitted you to pick the best.
Bolt awful je sais quoi and as a culminate inadequate familiarity by means
of consulting any rewording website reviews.
Utterly written testimonials purpose manual you through the dispose
of of selecting the united and purely transfiguration checking that last
will and testament fit your needs.
0 #6 arabic translation 2017-09-28 08:28
Businesses are erasing the boundaries between nations and as a result,
communication with the chief part in expanding your reach as entrepreneur.
Communication, in this matter, is the knack to spell out between any lingua franca pair there is
and the transfer services explode has made it steady
easier. You valid have to persuade unwavering the flock you trust your transference
offers objective accommodation, which can be verified by checking the reviews of the fastidious
0 #5 Elijah 2017-08-26 09:05
Então Air Band é lhe brincadeira. Download a este lugar.
0 #4 Damaris 2017-08-21 21:40
Get back to it, even if you forget for a day or two.
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