## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

Chapter    14

Arithmetic Operators

You use the arithmetic operators to do addition (+), subtraction (-), multiplication (*), and division (/). Generally, you use these operators in the same way you would in math (see Listing 14-1).

Listing 14-1. Arithmetic Operators

`let r1 = 1 + 2let r2 = 3 - 1let r3 = 6 * 5let r4 = 12 / 3`

If you are using arithmetic operators on two integers, then you can expect an integer result by default. All of the examples in Listing 14-1 will result in integer output. If one of the values is a Float or Double data type, then the result will be a floating-point data type as well.

Note  Be careful when dividing two integers since you can’t always be sure that the result will be an integer. You will not see the remainder ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required