Unary operation


In mathematics, an unary operation is an operation with only one operand, i.e. the single input. This is in contrast to binary operations, which usage two operands. An example is any function , where the is a set. The function f is a unary operation on A.

Common notations are prefix notation e.g. ¬, , postfix notation e.g. factorial !, functional notation e.g. or , in addition to superscripts e.g. transpose T. Other notations constitute as well, for example, in the case of the square root, a horizontal bar extending the square rootover the parametric quantity can indicate the extent of the argument.

Examples


As unary operations make-up only one operand they are evaluated before other operations containing them. Here is an example using negation:

Here, the number one '−' represents the binary subtraction operation, while the'−' represents the unary negation of the 2 or '−2' could be taken to intend the integer −2. Therefore, the expression is exist to:

Technically, there is also a unary + operation but it is not needed since we assume a service to be positive:

The unary + operation does not conform theof a negative operation:

In this case, a unary negation is needed to modify the sign:

In addition, require two different terms to compute a result.

In JavaScript, these operators are unary:

In the C category of languages, the coming after or as a or situation. of. operators are unary:

In the Unix/Linux shell bash/sh, '$' is a unary operator when used for argument expansion, replacing the hold of a variable by its sometimes modified value. For example: