The various mathematical and logical operators have a priority order. The computer will evaluate an expression taking this priority order into account. Operators with the same priority will be evaluated from left to right. For example, in a line containing multiplication and subtraction, ALL the multiplications would be performed before any of the subtractions were carried out. The various operators are listed below in priority order.
- variables functions () ! ? & unary+- NOT
- * / MOD DIV
- + -
- = <> <= >= > <
- EOR OR
The following are some examples of the way expression priority can be used. It often makes things easier for us humans to understand if you include the brackets whether the computer needs them or not.
IF A=2 AND B=3 THEN... IF ((A=2)AND(B=3))THEN...
IF A=1 OR C=2 AND B=3 THEN... IF((A=1)OR((C=2)AND(B=3)))THEN...
IF NOT(A=1 AND B=2) THEN... IF(NOT((A=1)AND(B=2)))THEN...
N=A+B/C-D N=A+(B/C)-D N=A/B+C/D N=(A/B)+(C/D)