Unary operation Information & Unary operation Links at HealthHaven.com
advertise
add site
services
publishers
database
health videos
Bookmark and Share

search wiki for    ?
web dir firms image gallery news pdf wiki shop video 
about
toolbar
stats
live show
health store
more stuff
JOIN/LOGIN
Featured Results:
PRODUCTS - Operator 's Manual : Imaging Diagnostic Systems Inc.,...
PRODUCTS - Operator's Manual : Imaging Diagnostic Systems Inc.,...
imds.com
 Vantage Oncology | Operator of Radiation Centers Reels in Partners - Los...
Vantage Oncology | Operator of Radiation Centers Reels in Partners - Los...
vantageoncology.com
 BioSpace Job Posting - Boiler House Operator
BioSpace Job Posting - Boiler House Operator
devicespace.com
 Lifeline Vascular Access » Physician Operator s Forum
Lifeline Vascular Access » Physician Operators Forum
lifelinevascularaccess.co...
 

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.

Contents

[edit] 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 two. 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)

[edit] Examples of unary operations

Generally, a unary operation on a given set S is a function SS, also called an endomorphism of S.

[edit] Computer programming

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

[edit] C family of languages

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

[edit] Other languages

[edit] 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

[edit] Usage of incremental and decremental operators

In most programming languages, incremental and decremental operators can be prefixed and suffixed to the variable. The prefix and suffix can be useful when manipulating variables. A suffixed operation increments the value after it has been called.

Order of evaluation for arguments in function calls is unspecified according to C99. Because of this, a compiler might produce results that appear to be transposed. The output of the examples below are compiler-specific and depends on implementation. To avoid this behavior and minimize dependence, the code could be rewritten.

In the examples below, the integer arguments are evaluated left to right.

[edit] Example 1

 int i = 0; printf (" %d \n %d ", i++, i++); 

Output:

 0 1 

Whereas a prefixed operation will increment the value before it has been called.

[edit] Example 2

 int i = 0; printf (" %d \n %d ", ++i, ++i); 

Output:

 1 2 

The usage of incremental and decremental operators is usually found in For loops.

[edit] $ in the Unix shell

In Unix shell scripting (usually bash) and other utilities such as Makefiles, the "$" is a unary operator that translates the name of a variable into its contents. Many people confuse this with a sigil (as used in PHP/Perl), but it is properly a unary operator for lexical indirection, similar to the * indirection operator for pointers in C. (This is why bash only uses $ when "reading" from variables, but not when "writing" to them.)

[edit] See also




Product Results (view all...)

search wiki for    ?
web dir firms image gallery news pdf wiki shop video 



↑ top of page ↑about thumbshots