C # 's subtraction operation

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.