# Expression order

The order in which the expression is calculated is determined by the operator precedence.

- Brackets e.g. ( and )
- Exponents e.g. 2 ^ 2
- Division e.g. 4 / 2
- Multiplication e.g. 4 * 2
- Addition e.g. 4 + 2
- Subtraction e.g. 4 - 2

This example demonstrates the operator precedence taking affect in two expressions.

    valueA as integer = 0
    valueB as integer = 0

    valueA = 2 + 10 / 2
    valueB = ( 2 + 10 ) / 2

    do
    	print ( valueA )
    	print ( valueB )

    	sync ( )
    loop

In the case of valueA the expression being assigned to it has the division calculated first, so 10 / 2 = 5, which is then added to 2 and assigned to valueA. Therefore this variable has a value of 7.

valueB has used brackets to force the addition to be calculated first. In this instance the result of 2 + 10 = 12 is divided by 2 giving the variable a value of 6.