Decimal numbers
All of the operations above have used whole numbers, more formally known as
integers. However, as you will know, not every number is whole. As an example, consider the following:
22 / 7
This, you may be surprised to know, results in the number 3. This is because if you only use integers in your expression, Swift makes the result an integer also. In this case, the result is rounded down to the next integer.
You can tell Swift to use decimal numbers by changing it to the following:
22.0 / 7.0
This time, the result is 3.142857142857143 as expected.