Unary expressions

Last update: Edit

A unary minus operator is used to convert a number from negative to positive or vice versa. Note: there is no unary plus.


represents the negative value of ‘8’. When used with a variable that already has a negative value (let’s assume $myVariable has the integer value “-7”) the result is positive: