Unary operation
From Wikipedia, the free encyclopedia
In mathematics, a unary operation is an operation with only one operand, i.e. an operation with a single input, or in other words, a function of one variable (for the terminology see also operators versus functions).
Common notations are prefix notation (+, -, not), postfix notation (factorial: n!), and functional notation (sin x or sin (x)). In the case of the square root a horizontal bar over the argument extending the square root sign can indicate the extent of the argument, so that parentheses can be dispensed with.
[edit] Examples of Unary Operations
- the absolute value operation is a unary operation on the real numbers
- the opposite operation (-x) on the real numbers
- the power operation (squaring, cubing, etc) on the real numbers
- the factorial operation on the real numbers
- the trigonometric operations (sin x, cos x, tan x, cot x, csc x) on the real numbers
- the natural logarithm (ln x) on the real numbers
- the logarithm of base 10 (log x) on the real numbers
- logical negation on truth values
- A unary operation on a given set S is nothing but a function S → S, also called an endomorphism of S.
[edit] Computer Programming
Unary operators (called "monadic" in APL) are also used in programming languages. For example, in the C family of languages, the following operators are unary:
- Increment: ++x, x++
- Decrement: --x, x--
- Address: &x
- Indirection: *x
- Positive: +x
- Negative: -x
- One's complement: ~x
- Logical negation: !x
- Sizeof: sizeof x
- Sizeof: sizeof(type-name)
- Cast: (type-name) cast-expression