Skip to content

Operators

Operators are used to perform calculations, comparisons and logical operations.


Arithmetic Operators

Arithmetic operators are used with numeric values.

Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division
% Remainder

Example

Int a : 10;
Int b : 5;

DisplayLog(a + b);
DisplayLog(a - b);
DisplayLog(a * b);
DisplayLog(a / b);

Output:

15
5
50
2

Comparison Operators

Comparison operators compare two values.

Operator Description
== Equal
!= Not equal
> Greater than
< Less than
>= Greater or equal
<= Less or equal

Example

Int age : 18;

DisplayLog(age == 18);
DisplayLog(age > 10);
DisplayLog(age < 5);

Output:

true
true
false

Logical Operators

Logical operators are used with boolean values.

Operator Description
&& And
|| Or
! Not

Example

Bool a : true;
Bool b : false;

DisplayLog(a && b);
DisplayLog(a || b);
DisplayLog(!a);

Output:

false
true
false

Assignment Operators

Assignment operators modify variables.

Operator Description
= Assign
+= Add and assign
-= Subtract and assign
*= Multiply and assign
/= Divide and assign

Example

Int points : 10;

points += 5;
DisplayLog(points);

points *= 2;
DisplayLog(points);

Output:

15
30

Complete Example

Int x : 20;
Int y : 4;

DisplayLog(x + y);
DisplayLog(x > y);
DisplayLog(x == 20);

Output:

24
true
true