Unary operation

Unary operation

In mathematics, a unary operation is an operation with only one operand, i.e. a single input. Specifically, it is a function

f:\ A\to A

where A is a set. In this case f is called a unary operation on A.

Common notations are prefix notation (e.g. +, −, not), postfix notation (e.g. factorial: n!), functional notation (e.g. sin x or sin (x)), and superscripts (e.g. transpose AT). Other notation exists as well, for example 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.

Contents

Unary negative and positive

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

3 − −2

Here the first '−' represents the binary subtraction operation, while the second '−' represents the unary negation of the 2. Therefore, the expression is equal to:

3 − (−2) = 5

Technically there is also a unary positive but it is not needed since we assume a value to be positive:

(+2) = 2

Unary positive does not change the sign of a negative operation:

(+(−2)) = (−2)

In this case a unary negative is needed to change the sign:

(−(−2)) = (+2)

Computer programming

Unary operators (called "monadic" in APL) are also used in programming languages.

C family of languages

In the C family of languages, the following operators are unary:

Other languages

Windows PowerShell

  • Increment: ++$x, $x++
  • Decrement: −−$x, $x−−
  • Positive: +$x
  • Negative: $x
  • Logical negation: -not $x
  • Invoke in current scope: .$x
  • Invoke in new scope: &$x
  • Cast: [type-name] cast-expression

See also

References


Wikimedia Foundation. 2010.

Игры ⚽ Нужна курсовая?

Look at other dictionaries:

  • unary operation — vienvietė operacija statusas T sritis automatika atitikmenys: angl. monadic operation; unary operation vok. einstellige Operation, f; monadische Operation, f; unäre Operation, f rus. операция с одним операндом, f; унарная операция, f pranc.… …   Automatikos terminų žodynas

  • unary operation — vienvietė operacija statusas T sritis informatika apibrėžtis ↑Operacija, turinti vieną ↑operandą. Operacijos ženklas paprastai rašomas prieš operandą, pavyzdžiui, –a, ¬a, rečiau po operando, pvz. a . atitikmenys: angl. unary operation ryšiai: dar …   Enciklopedinis kompiuterijos žodynas

  • unary operation — noun an operation with exactly one operand • Syn: ↑monadic operation • Hypernyms: ↑operation * * * an operation in a mathematical system by which one element is used to yield a single result, as squaring or taking the square root. Cf. binary… …   Useful english dictionary

  • unary operation — an operation in a mathematical system by which one element is used to yield a single result, as squaring or taking the square root. Cf. binary operation, ternary operation. [1930 35] * * * …   Universalium

  • unary operation — noun An operation taking one operand like the square, factorial or absolute value operation …   Wiktionary

  • Unary — * Unary numeral system, the simplest numeral system to represent natural numbers * Unary operation, a kind of mathematical operator that has only one operand * Unary coding, an entropy encoding that represents a number n with n − 1 ones followed… …   Wikipedia

  • Operation — may refer to: Scientific operation Surgery, or operation An operation in mathematics: Unary operation Binary operation Arity In language, an operation is a word which represents a function (or instruction), rather than a term or name In computer… …   Wikipedia

  • Operation (mathematics) — The general operation as explained on this page should not be confused with the more specific operators on vector spaces. For a notion in elementary mathematics, see arithmetic operation. In its simplest meaning in mathematics and logic, an… …   Wikipedia

  • unary — 1. adjective a) Consisting of or involving a single element or component. Negation is a unary operation. b) Of an operation, function, procedure or logic g …   Wiktionary

  • Operation theory — In logic and mathematics, a finitary operation ω is a function of the form ω : X1 × … × Xk → Y. The sets Xj are the called the domains of the operation, the set Y is called the codomain of the operation, and the fixed non negative integer k… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”