Print

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..

Comments   

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

talking to: http://decorlab.com/groups/boutique-bio-595851086/ -
relevant internet site: http://www.shepherdshouseassembly.org/index.php/component/k2/itemlist/user/34339 - sneak a peek at this web-site.: http://lapdatphonggame.org/forum/User-AvaM41052.html - click through the next
internet site: http://heqgateway.com/viewtopic.php?t=174053 - he said: http://lionkinggames.net/profile/roseanne447 - [url=http://bourdin.ru/?option=com_k2 boutique bio: http://www.bullfallsbrewery.com/ActivityFeed/MyProfile/tabid/58/UserId/186747/Default.aspx
Quote
 
 
0 #2 hypnose tabac lyon 2017-06-17 02:18
Thanks regarding delivering such substantial subject matter.



[url=http://www.s-i-p.dk/?option=com_k2u=1360 - http://freegameshd.com/index.php?task=profile&id=101904 - http://universidades-europe.com/?option=com_k2&view=itemlist&task=user&id=3773 - http://lovemeigui.com/space-uid-622194.html?do=profile

Also visit my web blog hypnose tabac lyon: http://lambertmarine.com/?option=com_k2&view=itemlist&task=user&id=17172
Quote
 
 
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: http://www.elisacavanna.club
Quote
 

Add comment


Security code
Refresh