Operators and precedence
The next table lists the EGL operators in order of decreasing precedence. Except for the unary plus (+), minus (–), and not (!), each operator works with two operands.
Operators (separated by commas) Type of operator Meaning +, – Numeric, unary Unary plus (+) or minus (-) is a sign before an operand or parenthesized expression, not an operator between two expressions. ** Numeric ** is the toThePowerOfInteger operator, which accepts a number to the specified power. For example c = a**b will result in c being assigned the value of (a^b). The first operand (a in the example above) cannot have a negative value. The second operand (b in the example above) must be an integer, or a numeric item with precision 0. The second operand can be positive, negative or 0. *, /, % Numeric Multiplication (*) and integer division (/) are of equal precedence. The division of integers retains a fractional value, if any; for example, 7/5 yields 1.4. % is the remainder operator, which resolves to the modulus when the first of two operands or numeric expressions is divided by the second; for example, 7%5 yields 2.
+, – Numeric Addition (+) and subtraction (–) are of equal precedence. = Numeric or string = is the assignment operator, which copies a numeric or character value from an expression or operand into an operand. ! Logical, unary ! is the not operator, which resolves to a Boolean value (true or false) opposite to the value of a logical expression that immediately follows. That subsequent expression must be in parentheses. =, != , <, >, <=, >=, in, is, not Logical for comparison The logical operators used for comparison are of equal precedence and are described in the page on logical expressions. Each operator resolves to true or false. && Logical && is the and operator, which means "both must be true." The operator resolves to true if the logical expression that precedes the operator is true and if the logical expression that follows the operator is true; otherwise, && resolves to false. || Logical || is the or operator, which means "one or the other or both." The operator resolves to true if the logical expression that precedes the operator is true or if the logical expression that follows the operator is true or if both are true; otherwise || resolves to false. You may override the usual precedence (also called the order of operations) by using parentheses to separate one expression from another. Operations that have the same precedence in an expression are evaluated in left-to-right order.
The equal sign (=) is used in two ways:
- As a operator for logical comparison, as described in the page on logical expressions
- As an assignment operator, which copies numeric or string values to an operand on the left side of an assignment statement; for example:
myItem01 = "Fascinating";
Related reference
Items
in operator
Logical expressions
Numeric expressions
Primitive types
Text expressions