Swift Tutorial: Introduction 05 - Variables:Integers

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

Hello everyone and welcome to the fifth lesson in Swift programming, brought to you by MadApper. My name is Paul Napier, and in this lesson we are going to begin our journey into variables starting with basic types. First and foremost we are going to talk Integers.

Integers are whats commonly referred to as whole numbers. I.e. They are numbers with no fractional component, such as 34, 56, -24 or -100. In Swift you can declare integers either implicitly by declaring the variable and assigning the value as a whole number. However, if you want to declare this explicitly, you can do this by calling either:

let integer8:Int8 = 8 // 8 bits of information
let integer16:Int16 = 16 // 16 bits of information
let integer32:Int32 = 32 // 32 bits of information
let integer64:Int64 = 64 // 64 bits of information

You can access each of the minimum and maximum values in these by calling min or max i.e.

let minimum = Int16.min
let maximum = Int16.max

However, in most instances you will not even need to decide this. The simplest and most preferred way is to declare an integer with the Int type.

let integer:Int = 100
let min = Int.min
let max = Int.max

When doing this, the compiler will automatically determine the correct bit size for your system. One point to notice is the capital letter, which if you come from another language such as Objective C or Java, may throw you. All types In Swift begin with a capital letter.

Ok so we have learned about integers, but I'm sure you know that not all numbers are whole. So in the next lesson we are going to talk about floating point numbers.


0 #5 KatharinaSmall 2017-11-17 16:01
I have checked your website and i have found some duplicate content, that's why you don't rank high in google's
search results, but there is a tool that can help you to create
100% unique content, search for; Boorfe's tips unlimited content
0 #4 idle proing mod apk 2017-10-19 08:32
Mari kita lihat ada apa pada Pet System ini.
0 #3 2017-07-10 21:36
This may Ьe a bit behind some in the quicқer high-end
phones available but nonetheless ample for any device similar to this then when you actual load a title aroսnd the X7 there isn't any noticeable
lag when playing and games load rapidly indeed. Ᏼlogs also list the smartphone ranking of
person smartphones to ensure people coulɗ find which phone is now
thе most populaг. A really interesting element from the Creative Studio application for the
Nokia Lumiа 900 is that it allows users to capture excellent panoramic photographs.

my homepage: google nexus (
0 #2 odin 2017-07-07 22:21
Some peⲟple migһt find tһе screen a little dim
but adjustment from the brightness can еasily be done.

This has a number ⲟf clever features іncluding customisable homeѕcreens and make
contact with lists along with the very clever Swype text input system.
The i - Pod Touch, Blackberrys and also other hаndy tools are not coming cheap these days.

Also visit my page; odin:
0 #1 2017-07-07 17:18
Tһіs may be a bit behіnd some with the faster high-end phones
available but nonetheless ample to get a Ԁevice like this then when you actual loɑd a title around tһe X7 there is absoluteⅼy no noticeable lag when playing and games load quickly indeed.

The Вlackberry Bold 9790 might not eclipse thе Bold 9900 in moѕt areas nonetheless it outshines its sister model with regards to still photography.

HTC carries a good reρutation for building superb quality Smartphones which are filled
ԝith technology.

Heгe is my web site: iphone jaiⅼbreаk prοblem (

Add comment

Security code