Skip to content

Operator

CD2 edited this page Feb 9, 2023 · 8 revisions

Postfix

Symbol Description
++ Increment an integer. The value of the expression is the value before the increment.
-- Decrement an integer. The value of the expression is the value before decrementing.
!! Inverts its own bool value and assigns it. The value of the expression is the value before inversion.
(: argument :) Make a call to a function pointer.

Prefix

Symbol Description
"+" Leaves its value as an integer.
"-" Reverses the sign of a signed integer. Take two's complement for unsigned integers.
! Find the NOT of a bool value and an integer.
"#" Finds the absolute value of a number. For reference types, find the length.
++ Increment an integer. The value of the expression is the value after incrementing.
-- Decrement an integer. The value of the expression is the value after decrementing.
!! Inverts its own bool value and assigns it. The value of the expression is the value after inversion.
' ' Convert the value to a string.
( type ) do the cast.

Binary operators (right associative)

Symbol Description
$ Makes the value on the right the value of the expression.
** Exponential calculation of floating point numbers.

Binary operators (left associative)

Symbol Description
"*" Multiply numbers.
"/" Divide numbers.
% Takes the remainder of integer division.
"+" Add numbers.
"-" Subtract numbers.
<< Performs a left bit shift of an integer.
">>" Performs a right bit shift of an integer.
< Finds if the left value is less than the right value.
<= Determines whether the left value is less than or equal to the right value.
">" Determines if the left value is greater than the right value.
">=" Determines if the left value is greater than or equal to the right value.
== Determines if the left and right values ​​are equal. For reference types, it asks if the referencing objects are on the same array.
!= Determines if the left and right values ​​are outliers. For reference types, it asks if the referencing is on a different array.
& Takes the AND of two integers or bool values.
^ Takes the XOR of two integers or bool values.
&& Takes a logical AND (short-circuit evaluation).

Ternary

Symbol Description
Condition ? Expression 1 : Expression 2 Evaluates expression 1 if the condition is true, and evaluates expression 2 otherwise.

Assignment operator (right associative)

Symbol Description
= Assign the right value.
**= Assigns the left value to the power of the right value.
*= Assign the product of the left and right values.
/= Assigns the quotient of the left and right values.
%= Substitutes the remainder of the left and right values.
+= Assigns the sum of the left and right values.
-= Substitute the difference between the left and right values.
<<= Assigns the value obtained by shifting the left value by the amount of the right value to the left.
">>=" Assigns the value obtained by right-bit-shifting the left value by the amount of the right value.
&= Assigns the AND of the left and right values.
^= XOR the left and right values.

Concatenation operator (left associative)

Symbol Description
.= Concatenate the right value to the end of the list.
Clone this wiki locally