Subtraction operators can also be applied to integer types, real types, enumeration types, string types, and representative types. Its usage rules and addition operators are largely indistinguishable. The corresponding algorithm rules are given in table 7-3.
Table 7-3
|
Y |
+0 |
-0 |
+∞ |
-∞ |
NaN |
| X |
Z |
X |
X |
-∞ |
+∞ |
NaN |
| +0 |
-Y |
+0 |
+0 |
-∞ |
+∞ |
NaN |
| -0 |
-Y |
-0 |
+0 |
-∞ |
+∞ |
NaN |
| +∞ |
+∞ |
+∞ |
+∞ |
NaN |
+∞ |
NaN |
| -∞ |
-∞ |
-∞ |
-∞ |
-∞ |
NaN |
NaN |
| NaN |
NaN |
NaN |
NaN |
NaN |
NaN |
NaN |
Enumeration type Subtraction
Each type of enumeration implies the following predefined operators.
U operator-(E x,e y);
Where E is the enumeration type and U is the base type of E.
The operator is equivalent to the (u) x (u) Y) operation. In other words, the operator calculates the difference between the numeric value of "X and Y", and the result type is the base type of the enumeration.
E operator-(e x,u y);
The operator is equivalent to (E) ((U) xy). That is, the operator refers to subtracting the value of an enumerated base type from the value of an enumerated type.
Representative to remove
The subtraction operator is called a move when it acts on a variable of type delegate. The prototype is:
D operator-(d x,d y);
where d is a delegate type.