Unary Operators
A unary operator is an operator that operates on a single operand to the right of the operator.
Negation
The unary minus (-) operator negates the value of its operand, effectively changing its sign.
VAR
a : INT := 5;
END_VAR
print(-a); // -5
Logical
The NOT operator inverts the boolean value of its operand. If the operand is TRUE, the result is FALSE, and vice versa.
VAR
a : BOOL := FALSE; // a begins as FALSE
END_VAR
IF NOT a THEN // Condition evaluates to TRUE
a := NOT a; // The value of a is inverted from FALSE to TRUE
END_IF;
print(a); // TRUE
Bitwise
Inverts each bit of the operand. For any given bit, if it is 0 it becomes 1 and vice versa.
VAR
a : INT := 2;
END_VAR
printf(a, 'b3'); // 010
a := NOT a;
printf(a, 'b3'); // 101