Skip to content

Operator

mtbeek32 edited this page Jan 9, 2023 · 20 revisions

An Operator is a symbolic representation of a function to be applied on operands. This application is called an operation. Operands can be data items or literals.

In expressions with multiple operators, the precedence of the evaluation is based on the precedence order and the associativity within this order. Operators with lower orders are evaluated first.

Examples:

  • -3^2 is evaluated as (-3)^2 or pow(neg(3), 2) due to the higher precedence order of the unary sub operator.
  • a / b * c is evaluated as (a / b) * c or mul(div(a,b), c) due to the equal order and left to right associativity of the multiply and divide operator.
  • a?b:c?d:e is evaluated as a?b:(c?d:e) due to the right to left associativity of the immediate if operators.
  • a || b && c is evaluated as a || (b && c) or or(a, and(b, c) due to the higher precedence order of the and operator.

Use brackets to overrule the precedence rules.

Operator

Name

Order Precedence

Associativity

Description

Equivalent Function

+ (unary)

plus

0

right to left

+a means a

- (unary)

minus

0

right to left

-a means -a

sub

#

nrofrows

0

-

#u means number of rows of unit u

nrofrows

^

power

1

left to right

a ^ b means a to the b-th power

pow

!

subitem

1

left to right

a!b means subitem(a, b)

subitem

[..]

array access

1

left to right

a[b] means lookup(b, a) if b is a data item

lookup

[..]

value

1

left to right

a[b] means value(a,b) if b is a unit

value

*

multiply

2

left to right

a * b means a multiplied with b

mul

/

divide

2

left to right

a / b means a divided by b (spaces are necessary)

div

%

modulo

2

left to right

a % b means a modulo b

mod

+(binary)

plus

3

left to right

a + b means a plus b

add

- (binary)

minus

3

left to right

a - b means a minus b

sub

==

equal to

4

left to right

a == b means a equals b

eq

!=

not equal to

4

left to right

a b means a not equals b

not

<

less than

4

left to right

a < b means a less than b

lt

<=

less than or
equal to

4

left to right

a <= b means a less than or equal to b

le

>

greater than

4

left to right

a > b means a greater than b

gt

>=

greater than or
equal to

4

left to right

a >= b means a greater than or equal to b

ge

! (unary)

not

5

right to left

!a means not a

not

&&

and

6

left to right

a && b means a and b

and

or

7

left to right

a '''

? :

then else (in an iif expression)

8

right to left

cond-expr ? then-expr : else-expr

iif

Clone this wiki locally