Information Technology Reference
In-Depth Information
Unary Arithmetic Operators
The unary operators set the sign of a numeric value. They are listed in Table 8-16.
￿
The unary positive operator simply returns the value of the operand.
￿
The unary negative operator returns the value of the operand subtracted from 0.
Table 8-16. The Unary Operators
Operator
Name
Description
+
Positive sign
Returns the numeric value of the operand
-
Negative sign
Returns the numeric value of the operand subtracted from 0
For example, the following code shows the use and results of the operators:
int x = 10; // x = 10
int y = -x; // y = -10
int z = -y; // z = 10
Search WWH ::




Custom Search