Operators

Operators combine, compare and update values with predictable type-directed semantics.

Arithmetic and comparison

Arithmetic+   -   *   /   %
Comparison==   !=   <   <=   >   >=
int total = a + b * 2;
bool ordered = a <= b;

Numeric operations use matching operand types. Comparison expressions produce bool.

Boolean and bitwise

Boolean&&   ||   !
Bitwise&   |   ^   ~   <<   >>

&& and || evaluate the right-hand expression only when its value is required.

bool canRun = ready && !failed;
uint masked = value & 0xFF;

Assignment and updates

Simple and compound assignment update an addressable value. Prefix and postfix forms increment or decrement numeric values.

value = 10;
value += 5;
value <<= 1;

i++;
--count;
+=-=*=/=%=&=|=^=<<=>>=