The unary -
operator works exactly as one would expect, it changes the postive/negative aspect of a number without changing its magnitude. For zero, which has neither a positive aspect nor a negative aspect, unary -
yields zero. So, for any number apart from 0, unary -
gives a result which is different from the operand.
Except for the bug, -0. The expression -&H80000==&H80000
evaluates to TRUE
.
This operator is in the unary precedence group, which is the highest. This means all unary operators are evaluated before any others, e.g. addition, so -7+2
is evaluated as (-7)+2
. Since all unary operators are prefixes to their operands, they are right-associative, i.e. the rightmost ones are evaluated first.