Data Types in Swift
Swift Data Types:
In Swift, data types specify the type of data that can be stored inside a variable. There are mainly eight types of data types in Swift programming.
1. Int: Integers are whole numbers with no fractional component, such as 25 and -25. Integers are either signed (positive, zero, or negative) or unsigned (positive or zero). Swift provides signed and unsigned integers in 8, 16, 32, and 64-bit forms.
2. Float: Float is used to represent a 32-bit floating-point number and numbers with smaller decimal points.
3. Double: Double represents a single-bit floating point number. Programmers need to use it when floating point values are very large or particularly precise.
4. Bool: Bool represents a Boolean value, which is either true or false.
5. String: It is an ordered collection of characters as a single unit. The string data type is used to represent textual data. For example, “Hello, World!”
6. Character: It is a single-character string literal. the character data type is used to represent a single-character string. For example, “C”
7. Optional: Optional represents a variable that can hold either a value or no value.
8. Tuples: Tuples is used to group multiple values in a single Compound Value.