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)
Unary operators (called "monadic" in APL) are also used in programming languages.
Read more about this topic: Unary Operation
Famous quotes containing the words negative and/or positive:
“In a country where misery and want were the foundation of the social structure, famine was periodic, death from starvation common, disease pervasive, thievery normal, and graft and corruption taken for granted, the elimination of these conditions in Communist China is so striking that negative aspects of the new rule fade in relative importance.”
—Barbara Tuchman (19121989)
“If all political power be derived only from Adam, and be to descend only to his successive heirs, by the ordinance of God and divine institution, this is a right antecedent and paramount to all government; and therefore the positive laws of men cannot determine that, which is itself the foundation of all law and government, and is to receive its rule only from the law of God and nature.”
—John Locke (16321704)