Operators

<< Click to Display Table of Contents >>

Navigation:  Project > Scripts > ST language > Operators and Expressions in STL >

Operators

Previous pageReturn to chapter overviewNext page

There are several operators available in Structured Text language:

Operation

Symbol

Precedence

Parenthesization

(expression)

Highest

Negation

Complement

-

!

 

Multiply

Divide

Modulo

*

/

%

 

Add

Subtract

+

-

 

Left Shift

Right Shift

<<

>>

 

Comparison

<, >, <=, >=,==,!=

 

Boolean AND

Boolean OR

Boolean XOR

&

||

^

Lowest

All the operators in the table above are sorted after precedence. This is also called order of operations, and you may know about if from mathematics.The order of operations is the order in which the operations are executed or calculated. Just take a look at this expression:

A + B * C

How will this expression be evaluated by the compiler? There are two operations left: multiply and addition. But since multiply has a higher precedence, that will be the first to be evaluated. B * C comes first and then the result is added to A. Every time an expression is evaluated, the evaluation follows the order of precedence as in the table above.

 

4 Types of Operators, 4 Types of Expressions


The operators used for expressions in Structured Text can be divided into four groups. Each group of operators will have its specific function and will yield a specific data type:

1. Arithmetic Operators

2. Relational Operators

3. Logical Operators

4. Bitwise Operators