Parenthesis (  )

Operator - Force the evaluation order in a complex expression.

Remarks

  • Parentheses are used in ST and IL languages for changing the default evaluation order of various operations within a complex expression.
  • Example: The default evaluation of 2 * 3 + 4 expression in ST Language gives a result of 10 because * operator has the highest priority.
    • Changing the expression as 2 * ( 3 + 4) gives a result of 14.
  • Parentheses can be nested in a complex expression.

These are the default evaluation priority order for ST language operations:

Priority

Operation

Description

1

- NOT

Unary operators

2

* /

Multiply / Divide

3

+ -

Add / Subtract

4

< > <= >= = <>

Comparisons

5

& AND

Boolean And

6

OR

Boolean Or

7

XOR

Exclusive OR

FBD Language Example

Not available.

FFLD Language Example

Not available.

IL Language Example

  • In the IL Language:
    • The default order is the sequence of instructions.
      • Each new instruction modifies the current result sequentially.
    • The opening parenthesis "(" is written between the instruction and its operand.
      • The closing parenthesis ")" must be written alone as an instruction without operand.
Op1: FFLD(  IN1
     ADD( IN2
     MUL  IN3
     )
     SUB  IN4
     )
     ST   Q    (* Q is: (IN1 + (IN2 * IN3) - IN4) *)

ST Language Example

Q := (IN1 + (IN2 / IN 3)) * IN4;

See Also

Assignment :=