& | ^ Operator in Java

Source: Internet
Author: User

&, |, ^

When there is a Boolean expression on both sides, the comparison result is a Boolean expression.

However, if the two sides are digits.

The rule is to change the number to binary.

&, The two sides are the same as 1, and the difference is 0

|, If either side is 1, the value is 1.

^, The two sides are different

Eg:

3 & 5

3 0000 0011

5 0000 0101

0000 0001

Result: 1

3 | 5

3 0000 0011

5 0000 0101

0000 0111

Result: 7

3 ^ 5

3 0000 0011

5 0000 0101

0000 0110

Result: 6

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.