Skip to content

Function Definition Language Operators#

Operator Order of Precedence#

  • || boolean operator (left associative)
  • && boolean operator (left associative)
  • ! boolean operator (non-associative)
  • <, <=, >, >=, ==, != relational operators (left associative)
  • = assignment operator (right associative)
  • + and - operators (left associative)
  • *, / and % operators (left associative)
  • ^ operator (right associative)
  • unary - operator (non-associative)
  • ++ and -- operators (non-associative)

Mathematical Operators#

- expr
The result is the negation of the expression.
expr + expr
The result of the expression is the sum of the two expressions.
expr โ€“ expr
The result of the expression is the difference between the two expressions.
expr * expr
The result of the expression is the product of the two expressions.
expr / expr
The result of the expression is the quotient of the two expressions.
expr % expr
The result of the expression is the remainder of the division.
^ expr
The result of the expression is the value of the first expression raised to the second expression.
The second expression must be an integer.
( expr )
Alters the standard precedence to force the evaluation of the expression, e.g. a + b / c is not the same as (a + b) / c.

Variable Operators#

var refers to either a simple or an array variable.
A simple variable is just a name; an array variable is specified as name[expr] (array subscript may be an expression).

++var
The variable is incremented by one and the new value is the result of the expression.
--var
The variable is decremented by one and the new value is the result of the expression.
var++
The result of the expression is the value of the variable and the variable is then incremented by one.
var--
The result of the expression is the value of the variable and the variable is then decremented by one.
var = expr
The variable is assigned the value of the expression.
var op= expr
This is equivalent to var = var op expr with the exception that the var part is evaluated only once.
This can make a difference if var is an array.
op is one of the mathematical operators +, -, *, /, % or ^.

Relational Operators#

Relational expressions evaluate to either 0 (if the relation is false) or 1 (if the relation is true).
These may appear in any legal expression.

expr1 < expr2
The result is 1 if expr1 is strictly less than expr2.
expr1 <= expr2
The result is 1 if expr1 is less than or equal to expr2.
expr1 > expr2
The result is 1 if expr1 is strictly greater than expr2.
expr1 >= expr2
The result is 1 if expr1 is greater than or equal to expr2.
expr1 == expr2
The result is 1 if expr1 is equal to expr2.
expr1 != expr2
The result is 1 if expr1 is not equal to expr2.

Boolean Operators#

The result of all boolean operators is either 0 or 1 (for false and true), as in Relational expressions.

Any non-zero value is treated as 1.

! expr
The result is 1 if expr is 0, otherwise 0. (NOT)
expr && expr
The result is 1 if both expressions are nonโŒ€zero, otherwise 0. (AND)
expr || expr
The result is 1 if either expression is nonโŒ€zero otherwise 0. (OR)

Bitwise Operators#

~expr
Bitwise NOT
expr & expr
Bitwise AND
expr | expr
Bitwise OR
expr >> expr
Shift right
expr << expr
Shift left