首页 | 主题 | 图库 | 问答 | 文摘 | 原创 | 百科

历史 | 地理 | 人物 | 艺术 | 体育 | 科学 | 音乐 | 电影 | 信息技术 | 世界遗产

 开放、中立,源自维基百科

Personal tools

Unary operation

From Wikipedia, the free encyclopedia

Jump to: navigation, search

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

Examples of Unary Operations


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:

Usage of Incremental and Decremental Operators

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

Example 1

int i = 0;
printf (" %i \n %i ", i++ , i++ );
Output:
0
1

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

Example 2

int i = 0;
printf (" %i \n %i ", ++i, ++i);
Output
1
2
The usage of incremental and decremental operators is usually found in For loops

See also

de:Einstellige Verknüpfung et:Unaarne tehe es:Operación unaria gl:Operación it:Operazione unaria he:פעולה יונארית nl:Unaire bewerking pt:Operação unária ja:単項演算 ru:Унарная операция sl:Enočlena operacija sv:Unär operator th:การดำเนินการเอกภาค

Languages
AD Links