Chapter 8 : Datatype : Floating Points

Datatype : Floating Points

Floating points are fractions (decimal numbers), they can be signed or unsigned.

What is a Floating Points

Examples : -11.456, 30.12, 0.5

Swift supports both signed and unsigned floating points. They range of floating points are much larger than that of integers. There are two types of floating points numbers in Swift

1. Double

2. Float

Note : Swift is a type safe language, when you assign a variable or a constant a decimal number, it always chooses it to be a Double rather then a float.

When we combine a Int with a Float the resulting value is of type Double

Example : var total = 23 + 1.3040 : total will be assigned as Double.