Expressions and Operators

Expressions and Operators

Expressions are evaluated left-to-right and from the inside out (in nested functions). Parentheses may be used to alter the default evaluation order of precedence for all operators.

Arithmetic Operators

Standard arithmetic operators are supported for use in expressions, listed here in their evaluation precedence.


* , /, %, and DIV all have the same precedence and are left associative. + and - have the same precedence and are left associative.

Division /
Integer DivisionDIV
Modulus Division%

Division by zero defaults to generating a zero result (0), rather than reporting a "divide by zero" error. This avoids invalid or unexpected data aborting a long job. The default behaviour can be changed using

#OPTION ('divideByZero', 'zero'); //evaluate to zero

The divideByZero option can have the following values:

'zero'Evaluate to 0 - the default behaviour.
'fail'Stop and report a division by zero error.
'nan'This is only currently supported for real numbers. Division by zero creates a quiet NaN, which will propagate through any real expressions it is used in. You can use NOT ISVALID(x) to test if the value is a NaN. Integer and decimal division by zero continue to return 0.

Bitwise Operators

Bitwise operators are supported for use in expressions, listed here in their evaluation precedence:

Bitwise AND&
Bitwise OR|
Bitwise Exclusive OR^

Bitshift Operators

Bitshift operators are supported for use in integer expressions:

Bitshift Right>>
Bitshift Left<<

Comparison Operators

The following comparison operators are supported:

Equivalence=returns TRUE or FALSE.
Not Equal <>returns TRUE or FALSE
Not Equal!=returns TRUE or FALSE
Less Than<returns TRUE or FALSE
Greater Than>returns TRUE or FALSE
Less Than or Equal <=returns TRUE or FALSE
Greater Than or Equal>=returns TRUE or FALSE
Equivalence Comparison<=>returns -1, 0, or 1

The Greater Than or Equal operator must have the Greater Than (>) sign first. For the expression a <=> b, the Equivalence Comparison operator returns -1 if a<b, 0 if a=b, and 1 if a>b. When STRINGs are compared, trailing spaces are generally ignored. Standard library functions, such as Std.Str.Find(), may consider trailing spaces. See the Standard Library Reference for specific details.