Order of precedence

The order of precedence is the order in which the operations are carried out for an expression. The order of precedence for sanScript is:

 

Exercise caution when you use bit-wise operators in expressions. Based on the order of precedence, you may not get the result you expect. For example, the following two expressions look similar, but are evaluated very differently:

if ((int_val1 and int_val2) > 0)

if (int_val1 and int_val2 > 0)

The first expression performs a bit-wise and operation on the two integer values and then compares the result to 0. The second expression compares the second integer value to 0 and then performs a bitwise and operation on that boolean result and int_val1. The second expression can’t be compiled because sanScript can’t perform a logical and operation on a boolean and an integer.


Documentation Feedback