English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
An operator is a symbol that tells the compiler to perform a specific mathematical or logical operation.
Arithmetic operators
Relational operators
Logical operators
Bitwise Operators
Operator | Description | Example |
---|---|---|
+ | Two operands are added | 1 + 2 = 3 |
− | The first operand is subtracted from the second operand | 1 - 2 = -1 |
* | Two operands are multiplied | 2 * 2 = 4 |
/ |
By dividing the numerator by the denominator | 2 / 2 = 1 |
rem |
The remainder when the second number is divided by the first number | 3 rem 2 = 1 |
div |
The div component will perform division and return the integer part | 3 div 2 = 1 |
Operator | Description | Example |
---|---|---|
== | Tests if two objects are equal | 2 = 2 Results in true |
/= | Tests if two objects are not equal | 3 /= 2 Results in true |
< | Tests if the left object is less than the right operand object | 2 < 3 Results in true |
<= | Tests if the left object is less than or equal to the right operand object | 2 <=3 Results in true |
> | Tests if the left object is greater than the right operand object | 3 > 2 Results in true |
>= | Tests if the left object is greater than or equal to the right operand object | 3 >= 2 Results in true |
Operator | Description | Example |
---|---|---|
or | Logical "or" operator | True or true results in true |
and | Logical "and" operator | True AND false results in false |
not | Logical 'not' Operator | NOT false results in true |
xor | Logical 'xor' Operator | True XOR false results in false |
S.No. | Operator & Description |
---|---|
1 | band Bitwise 'and' Operator |
2 | bor Bitwise 'or' Operator |
3 | bxor Bitwise 'xor' or Exclusive OR Operator |
4 | bnot
Bitwise NOT Operator |
p | q | p & q | p | q | p ^ q |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
0 | 1 | 0 | 1 | 1 |
1 | 1 | 1 | 1 | 0 |
1 | 0 | 0 | 1 | 1 |
Operators | Association |
---|---|
: | |
# | |
bnot,not | |
/,*,div,rem,band,and | Left Association |
+,-,bor,bxor,or,xor | Left Association |
==,/=,=<,<,>=,> |