Features of "Java" XOR "^"

Source: Internet
Author: User

1, what is XOR or

XOR is a logical operator, using the symbol "^" to indicate that XOR is in the process of binary operation, the same takes 0, different fetch 1.

2, prove a==a^b^b;

For this conclusion the reader must be aware that the results of B^b are certainly all 0, and then any number and 0 are different or will not change. So the A==A^B^B was established.

3, intermodulation two numbers using XOR features

If you need to adjust the number A and B, then you can:

int temp=a;a=b;b=temp;

You can also use XOR:

a=a^b;b=a^b;a=a^b;

Features of "Java" XOR "^"

Related Article

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.