Operators

Character

Meaning

Priority

!

~

Logical Negation, applicable to the type boolean

Binary Negation, applicable to the type integer

1 (highest)

*

/

%

Multiplication, applicable to the types integer and float

Division, applicable to the types integer and float

Modulo (to make remainder), applicable to the type integer

2

+

-

Addition, applicable to the types integer, float, time and string

Subtraction, applicable to the types integer, float and time

3

<<

>>

Bitwise shift to the left, applicable to the type integer

Bitwise shift to the right, applicable to the type integer

4

|

&

^

Bitwise OR, applicable to the type integer

Bitwise AND, applicable to the type integer

Bitwise exclusive OR, applicable to the type integer

5

==

!=

<

>

<=

>=

Equal to, applicable to all types

Not equal to, applicable to all types

Less than, applicable to the types integer, float, time and string

Greater than, applicable to the types integer, float, time and string

Less than or equal to, applicable to the types integer, float, time and string

Greater than or equal to, applicable to the types integer, float, time and string

6

||

&&

Logical OR, applicable to the type boolean

Logical AND, applicable to the type boolean

7 (lowest)

The negations ! and ~ are unary. They have only one operand and this must be to the right of the operator. All other operators are binary. They require two operands, one to the left and one to the right of the operator.

The logical conjunctions AND and OR are excluding. This means that the operand to the right of the operator will only be evaluated if the result of the conjunction can still change.

Apart from !, ~, ||, and &&, the operators can also be combined with an assignment. The statement:

variable = variable + 1;

can also be written as:

variable += 1;

Both statements are identical.

If an operation contains more than one operator, then the operators are evaluated according to the priorities listed in the tabel above, with the highest priority being evaluated first. If priorities are equal, the operation is evaluated from left to right:

2 + 4 * 3 / 2 - 1

You can use brackets to change the sequence in which the operation is evaluated:

(2 + 4) * 3 / (2 – 1)

With the exception of integer and float, types can not be mixed in an operation. For example, you cannot subtract a string from a number or a date. Similarly, you cannot add a number to a time, only another time.