# Unary minus

In mathematics , the unary minus is a one- digit operator that returns the negative of a number.

The unary minus is usually written with the same sign as the binary minus of the subtraction . The distinction between unary and binary minus is important in programming languages , since in many programming languages ​​(such as C , C ++ , Java ) the unary minus has a higher bond strength ( operator priority ).  −a·x is (−a)·xevaluated in these languages ​​as . Depending on the data type, value range and calculation accuracy, this can result in a different result than −(a·x).

However, this different bond strength does not apply in mathematics, which is why the unary minus usually has to be bracketed there. Example:

${\ displaystyle -x ^ {n} \,}$ means . If one thinks , this must be explicitly bracketed.${\ displaystyle - \ left (x ^ {n} \ right)}$ ${\ displaystyle (-x) ^ {n} \,}$ Some programming languages ​​(such as BASIC ) know both unary and binary minus, but do not give the unary minus a higher priority. An expression like is evaluated there like . −ax−(ax)

Today's compilers can usually distinguish between the unary and the binary minus. The unary minus should only be bracketed separately in exceptional cases.