Unary Expressions
Last modified: April 20, 2023
1 Introduction
An unary minus operator is used to convert a number from negative to positive or vice versa.
There is no unary plus.
2 Example
The example below represents the negative value of ‘8’.
-8
When used with a variable that already has a negative value the result is positive.
For example, if $myVariable has the integer value “-7”:
-$myVariable
The output is:
7
Feedback
Was this page helpful?
Glad to hear it! Thank you for your response.
Sorry to hear that. Please tell us how we can improve.