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:
“For those parents from lower-class and minority communities ... [who] have had minimal experience in negotiating dominant, external institutions or have had negative and hostile contact with social service agencies, their initial approaches to the school are often overwhelming and difficult. Not only does the school feel like an alien environment with incomprehensible norms and structures, but the families often do not feel entitled to make demands or force disagreements.”
—Sara Lawrence Lightfoot (20th century)
“Nurturing competence, the food of self-esteem, comes from acknowledging and appreciating the positive contributions your children make. By catching our kids doing things right, we bring out the good that is already there.”
—Stephanie Martson (20th century)