We are going to discuss Data Types in Swift article. This will solve all your doubts. Let’s go into the article.
The data type of any programming language is a set of information containing set meanings and unique variables. You must use different types of variables to store information during programming in any programming language.
The data type of any programming language is a set of data with fixed meanings and variables that are unique.
Data Types in Swift
- Int or UInt − It is used for integers. More specifically, Int32 can use Int64 to define a 32 or 64 bit signed integer, while UInt32 or UInt64 can be used to define 32 or 64 bit unsigned integer variables.
- Float − It is used to denote 32-bit floating point numbers and numbers with smaller decimal points. For example, 3.14159, 0.1 and -273.158.
- Double − It is used to indicate a 64-bit floating point number and the floating point values must be very large. For example, 3.14159, 0.1 and -273.158.
- Bool − It refers to the Boolean value, which is true or false.
- String − This is a collection of sorted characters. For example, “Hello, world!”
- Character − This is a single character string. For example, “C”
- Optional − This represents a variable that can hold either a value or no value.
- Tuples − This is used to group multiple values in single Compound Value.
the maximum and minimum values which can be stored in such types of variables:
|Int8||1byte||-127 to 127|
|UInt8||1byte||0 to 255|
|Int32||4bytes||-2147483648 to 2147483647|
|UInt32||4bytes||0 to 4294967295|
|Int64||8bytes||-9223372036854775808 to 9223372036854775807|
|UInt64||8bytes||0 to 18446744073709551615|
|Float||4bytes||1.2E-38 to 3.4E+38 (~6 digits)|
|Double||8bytes||2.3E-308 to 1.7E+308 (~15 digits)|
Data Types in Swift We hope you find this article very useful. Let us know how this article helps you through the comment box.