Unary operation
|
In mathematics, a unary operation is an operation with only one operand. For instance, logical negation is a unary operation on truth values and squaring is a unary operation on the real numbers. Another unary operation is the factorial, n!. A unary operation on the set S is nothing but a function S → S.
Unary operator are also used in programming languages. For example in the C++ programming language, 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)
- Cast: (type-name) cast-expression