Priya Talreja avatar

Chapter 8 - Types of Data

priyatalreja

Published: 28 May 2018 › Updated: 28 May 2018Chapter 8 - Types of Data

Chapter 8 - Types of Data

In any programming language, we use different types of variables to store information. Variables are nothing but reserved memory locations to store values.

Int

  • Int which short for Integer.
  • Integers are round numbers like 3, 30, 300, or -16777216.
  • You can use Int32, Int64 to define 32 or 64 bit signed integer.
  • On a 32-bit platform, Int is the same size as Int32.
  • On a 64-bit platform, Int is the same size as Int64.

UInt

  • Swift also provides an unsigned integer type UInt.
  • Use UInt only when you specifically need an unsigned integer type.

String

  • A string is a series of characters.
  • Swift strings are represented by the String type.

Bool

  • Swift has a basic Boolean type, called Bool.
  • Boolean values are referred to as logical, because they can only ever be true or false.

Float

  • This is used to represent a 32-bit floating-point number and numbers with smaller decimal points.

Double

  • This is used to represent a 64-bit floating-point number and used when floating-point values must be very large.
  • The official Apple recommendation is always to use Double because it has the highest accuracy.
  • Double has twice the accuracy of Float so it doesn't need to cut the ​number to fit.

Swift Datatypes Priya Talreja

My next blog will be on Strings and Characters.

Priya Talreja Xcode Tutorials
Please let me know if you have any doubts or queries in the comment section below.
Follow me priyatalreja@priyatalreja to get the latest feeds of iOS App step by step development tutorials.
Thanks.

Leave Chapter 8 - Types of Data to:

Written by

Developer

Read more #swift posts


Best Posts From Priya Talreja

We have not curated any of priyatalreja's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Priya Talreja