TheInfoList

In
mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities and their changes (cal ...
, a unary operation is an operation with only one
operand In mathematics an operand is the object of a mathematical operation, i.e., it is the object or quantity that is operated on. Example The following arithmetic expression shows an example of operators and operands: :3 + 6 = 9 In the above example, ...
, i.e. a single input. This is in contrast to
binary operation In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). I ...
s, which use two operands. An example is the function , where ''A'' is a set. The function ''f'' is a unary operation on ''A''. Common notations are
prefix notation Polish notation (PN), also known as normal Polish notation (NPN), Łukasiewicz notation, Warsaw notation, Polish prefix notation or simply prefix notation, is a mathematical notation in which Operation (mathematics), operators ''precede'' their ...
(e.g.
+ , , ¬),
postfix notation Reverse Polish notation (RPN), also known as Polish postfix notation or simply postfix notation, is a mathematical notation in which operators ''follow'' their operands, in contrast to Polish notation (PN), in which operators ''precede'' their ...
(e.g.
factorial In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers ( and ), formulas and related structures (), shapes and spaces in which they are contained (), and quantities and their changes ( and ). There is no g ...
n!), functional notation (e.g. sin ''x'' or sin(''x'')), and
superscript Pro; the size of the subscript is about 62% of the original characters, dropped below the baseline by about 16%. The second typeface is Myriad A myriad (from Ancient Greek Ancient Greek includes the forms of the Greek language used in a ... s (e.g.
transpose In linear algebra Linear algebra is the branch of mathematics concerning linear equations such as: :a_1x_1+\cdots +a_nx_n=b, linear maps such as: :(x_1, \ldots, x_n) \mapsto a_1x_1+\cdots +a_nx_n, and their representations in vector spaces an ... ''A''T). Other notations exist as well. For example, in the case of the
square root In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis) ... , a horizontal bar extending the square root sign over the argument can indicate the extent of the argument.

# Examples

## 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 In logic Logic is an interdisciplinary field which studies truth and reasoning Reason is the capacity of consciously making sense of things, applying logic Logic (from Ancient Greek, Greek: grc, wikt:λογική, λογική, ... : :3 − −2 Here, the first '−' represents the binary
subtraction Subtraction is an arithmetic operation that represents the operation of removing objects from a collection. Subtraction is signified by the minus sign, . For example, in the adjacent picture, there are peaches—meaning 5 peaches with 2 taken ... operation, while the second '−' represents the unary negation of the 2 (or '−2' could be taken to mean the integer −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 The 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)

## Trigonometry

In
trigonometry Trigonometry (from ', "triangle" and ', "measure") is a branch of that studies relationships between side lengths and s of s. The field emerged in the during the 3rd century BC from applications of to . The Greeks focused on the , while ... , the trigonometric functions, such as $\sin$, $\cos$, and $\tan$, are unary operations. This is because it is possible to provide only one term as input for these functions and retrieve a result. By contrast, binary operations, such as
addition Addition (usually signified by the plus symbol The plus and minus signs, and , are mathematical symbol A mathematical symbol is a figure or a combination of figures that is used to represent a mathematical object A mathematical object is an ... , require two different terms to compute a result.

## Examples from programming languages

### Javascript

In
Javascript JavaScript (), often abbreviated JS, is a programming language A programming language is a formal language In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), ma ...
, these operators are unary: *
Increment Increment or incremental may refer to: *Incrementalism, a theory (also used in politics as a synonym for gradualism) *Increment and decrement operators, the operators ++ and -- in computer programming *Incremental computing *Incremental backup, whi ...
: ++x, x++ * Decrement: −−x, x−− *Positive: +x *Negative: −x *
Ones' complement The ones' complement of a binary number In mathematics and digital electronics Digital electronics is a field of electronics The field of electronics is a branch of physics and electrical engineering that deals with the emission, behavi ...
: ~x *
Logical negation In logic Logic (from Ancient Greek, Greek: grc, wikt:λογική, λογική, label=none, lit=possessed of reason, intellectual, dialectical, argumentative, translit=logikḗ)Also related to (''logos''), "word, thought, idea, argume ... : !x

### C family of languages

In the C family of languages, the following operators are unary: *
Increment Increment or incremental may refer to: *Incrementalism, a theory (also used in politics as a synonym for gradualism) *Increment and decrement operators, the operators ++ and -- in computer programming *Incremental computing *Incremental backup, whi ...
: ++x, x++ * Decrement: −−x, x−− *
Address An address is a collection of information, presented in a mostly fixed format, used to give the location of a building, apartment, or other structure or a plot of land, generally using political boundaries Borders are geographic Geogr ...
: &x *
IndirectionIn computer programming Computer programming is the process of designing and building an executable computer program to accomplish a specific computing result or to perform a specific task. Programming involves tasks such as: analysis, generatin ...
: *x *Positive: +x *Negative: −x *
Ones' complement The ones' complement of a binary number In mathematics and digital electronics Digital electronics is a field of electronics The field of electronics is a branch of physics and electrical engineering that deals with the emission, behavi ...
: ~x *
Logical negation In logic Logic (from Ancient Greek, Greek: grc, wikt:λογική, λογική, label=none, lit=possessed of reason, intellectual, dialectical, argumentative, translit=logikḗ)Also related to (''logos''), "word, thought, idea, argume ... : !x *
Sizeof sizeof is a unary operator In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathemati ...
: sizeof x, sizeof(type-name) *
Cast Cast may refer to: Music * Cast (band) Cast are an English indie rock band formed in Liverpool Liverpool is a City status in the United Kingdom, city and metropolitan borough in Merseyside, England. Its population in 2019 was approxim ...
: (''type-name'') ''cast-expression''

In the Unix/Linux shell (bash/sh), '$' is a unary operator when used for parameter expansion, replacing the name of a variable by its (sometimes modified) value. For example: * Simple expansion: $x * Complex expansion: $ ### Windows PowerShell *Increment: ++$x, $x++ *Decrement: −−$x, $x−− *Positive: +$x *Negative: −$x *Logical negation: !$x * Invoke in current scope: .$x *Invoke in new scope: &$x *Cast:  'type-name''''cast-expression'' *Cast: +$x *Array: ,$array

*
Binary operation In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities and ...
*
Iterated binary operationIn mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It ha ...
*
Ternary operationIn mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It ha ...
*
Arity Arity () is the number of arguments In logic Logic (from Ancient Greek, Greek: grc, wikt:λογική, λογική, label=none, lit=possessed of reason, intellectual, dialectical, argumentative, translit=logikḗ)Also related to (''logo ...
*
Operation (mathematics) In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities and ...
*
Operator (programming) In computer programming Computer programming is the process of designing and building an executable In computing, executable code, an executable file, or an executable program, sometimes simply referred to as an executable or binary, cau ...

*