Order of Evaluation
Expressions are usually evaluated from left to right.
For example,
10 - 3 + 2
└───┬───┘
│
│
7 + 2
└──────┬───┘
│
│
9
In other words, the value of: 10 - 3 +
2 is: 9.But some operations are given priority over others. The rules are
generally the same as in ordinary algebra. For example, multiply (*)
has a higher priority than subtract (-).
10 - 3 * 2
└───┬───┘
│
10 - 6
└─────┬────┘
│
4
In other words,
the value of: 10 - 3 * 2 is: 4.We shall discuss the rules of priority again in Reading 2 in Priority of Operators.