Chapter 8 - Types of Data

in swift •  6 years ago 
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 to get the latest feeds of iOS App step by step development tutorials.
Thanks.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Congratulations @priyatalreja! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

SteemitBoard - Witness Update
Vote for @Steemitboard as a witness to get one more award and increased upvotes!