Exclusive or operations ^ and a common role of others

Source: Internet
Author: User

Discover a new knowledge and introduce it to you:

Binary exclusive or operation:The two are equal to 0, not equal to 1.

In this way, we find that the third parameter is not required when two integers are exchanged.
For example, a = 11, B = 9. The following is binary.
A = a ^ B = 1011 ^ 1001 = 0010;
B = B ^ A = 1001 ^ 0010 = 1011;
A = a ^ B = 0010 ^ 1011 = 1001;
In this case, a = 9 and B = 11.

For example, you can exchange two Mc positions by pressing one button. VB

Mybt. onpress = function ()
{
Mc1. _ x = mc1. _ x ^ mc2. _ x;
Mc2. _ x = mc2. _ x ^ mc1. _ x;
Mc1. _ x = mc1. _ x ^ mc2. _ x;
//
Mc1. _ y = mc1. _ y ^ mc2. _ y;
Mc2. _ y = mc2. _ y ^ mc1. _ y;
Mc1. _ y = mc1. _ y ^ mc2. _ y;
}

In this way, it can be passed without monitoring variables.

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.