Unary Expressions

Last update: Edit

1 Introduction

An unary minus operator is used to convert a number from negative to positive or vice versa.

2 Example

The example below represents the negative value of ‘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”:


The output is: