Operators
Jump to navigation
Jump to search
Navigation: PGMs ➔ Operators
Contents
Operators Summary
Arithmetic  Logical  Comparison  Bitwise  Miscellaneous  

+
 * / ^ 
Addition Subtraction Multiplication Division Power 
AND
OR XOR NOT 
Logical AND Logical OR Logical Exclusive OR Logical NOT 
<
<= > >= == <> != 
Less Than Less Than or Equal To Greater Than Greater Than or Equal To Equal To Not Equal To Not Equal To 
BAND
BOR BXOR BNOT 
Bitwise AND Bitwise OR Bitwise Exclusive OR Bitwise NOT 
( )  Roundbrackets 
Operator Precedence
The following table lists the precedence of each operator in descending order.
 The lines separate the different levels of operator precedence.
 Where consecutive operators occur having the SAME precedence, then they are carried out from left to right
 The Association column determines the order in which the operands are operated upon.
Symbol  Name or Meaning  Precedence (From Highest to Lowest) 

NOT BNOT  + 
Logical NOT Bitwise NOT Unary minus Unary plus 
Right to Left 
^  Power  Left to Right 
* / 
Multiply Divide 
Left to Right 
+  
Add Subtract 
Left to Right 
< <= > >= 
Less Than < Less Than or Equal To Greater Than Greater Than or Equal To 
Left to Right 
== <> OR != 
Equal To Not Equal To 
Left to Right 
BAND  Bitwise AND  Left to Right 
BXOR  Bitwise exclusive OR  Left to Right 
BOR  Bitwise OR  Left to Right 
AND  Logical AND  Left to Right 
XOR  Logical exclusive OR  Left to Right 
OR  Logical OR  Left to Right 
=  Assignment  Right to Left 
Operators
Operator  Symbol  Function  Description  Requirements / Evaluation Order 

Arithmetic Operators  
Addition  +  operand1 + operand2  This adds operand2 to operand1. 
The operands must be numeric variables. 
Subtraction    operand1  operand2  This subtracts operand2 from operand1.  
Multiplication  *  operand1 * operand2  This multiplies operand2 by operand1.  
Division  /  operand1 / operand2  This divides operand1 by operand2.  
Power  ^  operand1 ^ operand2  This raises operand1 to the power operand2.  
Comparison Operators  
Less than  <  Operand1 < Operand2  Determine the validity of the given comparison.

The operands must be numeric variables 
Less than or Equal to 
<=  Operand1 <= Operand2  
greater than  >  Operand1 > Operand2  
greater than or Equal to 
>=  Operand1 >= Operand2  
Equal to  ==  Operand1 = Operand2  
Not Equal to  <> OR != 
Operand1 <> Operand2 Operand1 != Operand2  
Logical Operators  
Logical AND  AND  expression1 AND expression2  Returns 1 if both expressions are True, Otherwise it returns 0. 
Evaluates Expression1, if it is true then expression2 is evaluated. 
Logical OR  OR  expression1 OR expression2  Returns 1 if either or both expressions are True, Otherwise it returns 0. 
Evaluates Expression1, if it is false then expression2 is evaluated. 
Logical Exclusive OR  XOR  expression1 XOR expression2  Returns 1 if either but NOT both expressions are True, Otherwise it returns 0. 
Both expressions are evaluated. 
Logical NOT  NOT  NOT expression  Returns 1 if expression is False, Returns 0 if expression is True. 

Bitwise Operators  
Bitwise AND  BAND  operand1 BAND operand2  Each bit of operand1 is compared with the corresponding bit of operand2.
 
Bitwise OR  BOR  operand1 BOR operand2  Each bit of operand1 is compared with the corresponding bit of operand2.
 
Bitwise Exclusive OR  BXOR  operand1 BXOR operand2  Each bit of operand1 is compared with the corresponding bit of operand2.
 
Bitwise NOT  BNOT  BNOT operand  This produces a bitwise complement of operand
 
Miscellaneous Operators  
Round Brackets  ( ) 

Notes
NOTES:
 Division by zero will result in an error as it is undefined. Please see How do I avoid a 'Divide by Zero' error? for ways of avoiding this error when using measured variables.
 Invalid operations (eg 0^0.5 or 3^0.5) will result in an error as it is undefined.
 See also Div and Mod.
Round Brackets Examples:
 Calculation:
 ...3 * (4 + 2)  ...
 In this case : 2 is added to 4 BEFORE the result is multiplied by 3.
 Logical
 ((variable1 > 5) AND (variable2 < variable3)) OR NOT variable4
 In this case, both variable1and variable2 must comply with the specified criteria or variable4 must be false, for this condition to be true.