Arithmetical Operations
Operator
|
Operand/
Data Type
|
Results In Data Type
|
Description
|
++, -- (as prefix, e.g. ++i)
|
int
|
int
|
Adds/subtracts 1 to/from the value of the operand. Superior expressions are evaluated after the value of the operand is changed.
|
++, -- (as suffix, e.g. i++)
|
int
|
int
|
Adds/subtracts 1 to/from the value of the operand. Superior expressions are evaluated before the value of the operand is changed.
|
+
|
int, float, string
|
Depends on operand data types. It will be converted into the more precise data type.
|
Calculates the sum of two operands or concatenates two character strings.
|
-, *, /
|
int, float
|
Depends on operand data types. It will be converted into the more precise data type.
|
Calculates the difference/product/quotient of two operands.
|
%
|
int
|
int
|
Calculates the remainder of an integer division.
|
»Description
Logical Operations
Operator
|
Operand/
Data Type
|
Results In Data Type
|
Description
|
!
|
bool
|
bool
|
This is the logical NOT. It negates the following operand.
|
||
|
bool
|
bool
|
This is the logical OR. The result is true if at least one operand is true. Both operands are evaluated in every single case.
|
&&
|
bool
|
bool
|
This is the logical AND. The result is true if both operands are true. Both operands are evaluated in every single case.
|
<, <=, >, >=, ==, !=
|
int, float, bool, string
|
bool
|
Compares two operands.
|
»Description
Bit Operations
Operator
|
Operand/
Data Type
|
Results In Data Type
|
Description
|
~
|
int
|
int
|
This is the bitwise NOT. It negates each bit of the following operand.
|
^
|
int
|
int
|
This is the bitwise XOR. Each bit of the result is set where the corresponding bits of the operands are different.
|
|
|
int
|
int
|
This is the bitwise OR. Each bit of the result is set where at least one of the corresponding bits of the operands is set.
|
&
|
int
|
int
|
This is the bitwise AND. Each bit of the result is set where both corresponding bits of the operands are set.
|
<<
|
int
|
int
|
Shifts the bits of the first operand by offset n to the left (n is the second operand). The rightmost (least significant) bits of the result are set to 0.
|
>>
|
int
|
int
|
Shifts the bits of the first operand by offset n to the right (n is the second operand). The leftmost (most significant) bits of the result are set to 0.
|
>>>
|
int
|
int
|
Shifts the bits of the first operand by offset n to the right (n is the second operand). The leftmost (most significant) bits of the result depend on the first operand which sign is preserved (i.e. negative numbers will not become positive by shifting to the right).
|
»Description
Assignment Operations
Operator
|
Description
|
=
|
A simple assignment. The left operand gets the value of the right one.
|
+=
|
For example: i += 4 corresponds to i = i + 4.
|
-=
|
For example: i -= 4 corresponds to i = i - 4.
|
*=
|
For example: i *= 4 corresponds to i = i * 4.
|
/=
|
For example: i /= 4 corresponds to i = i / 4.
|
%=
|
For example: i %= 4 corresponds to i = i % 4.
|
^=
|
For example: i ^= 4 corresponds to i = i ^ 4.
|
|=
|
For example: i |= 4 corresponds to i = i | 4.
|
&=
|
For example: i &= 4 corresponds to i = i & 4.
|
<<=
|
For example: i <<= 4 corresponds to i = i << 4.
|
>>=
|
For example: i >>= 4 corresponds to i = i >> 4.
|
>>>=
|
For example: i >>>= 4 corresponds to i = i >>> 4.
|
»Description
|