Operator Precedence
Top  Previous  Next


When several operations occur in an expression, scripting engine evaluates and resolves each part of the expression in a predetermined order. This predetermined order is known as operator precedence.
You can use parentheses to override the order of precedence and force some parts of an expression to be evaluated before other parts. Operations within parentheses are always performed before those outside the parentheses. Within parentheses standard operator precedence is maintained.

ImageWarp
organizes operators into three categories: arithmetic operators, comparison operators, and logical operators. When expressions contain operators from more than one category, the engine first evaluates arithmetic operators, then comparison operators, followed by logical operators. The following table shows the order of precedence for the evaluation of arithmetic and logical operators:

Arithmetic
Comparison
Logical
Exponentiation (^)
Equality (=)
not
Negation (-)
Inequality (<>)
and
Multiplication (*) and Division (/)
Less than (<)
or
Modulus Arithmetic (mod)
Greater than (>)
xor
Addition (+) and Subtraction (-)
Less than (<) or equal to (=)

Addition (+) and Subtraction (-)
Greater than (>) or equal to (=)

      


When multiplication and division occur together in an expression, the engine evaluates each operation as it occurs from left to right. Likewise, when addition and subtraction occur together in an expression, the engine evaluates each operation in order of appearance from left to right.

Comparison operators all have equal precedence; that is, the engine evaluates them from left to right in the order in which they appear.