The odd-and-even relationship between binary XOR and 1 numbers in binary numbers

Source: Internet
Author: User

Binary XOR or operation of the binary number of the 1 number of parity, that is to say there are three cases, 1. A binary number with an odd number of 1 and a binary number with an odd number of 1. 2. A binary number with an odd number of 1 and a binary number with an even number of 1. 3. A binary number with an even number of 1 and a binary number with an even number of 1.

Assuming that the total digit is W, the number one has x 0, the number two owns Y 0, and the number one 0 matches the number two of K 1 (k<=x).

Because the XOR or operation produces 1 only in two cases: the number of 0 and the number two of 1, the number of 1 and two of 0.

Number of the first case 1: K.

The second Case 1 number: The number one 0 and the number two 0 matches the number is x-k, this does not produce 1, then 1 's number should be: Y (x-k)

So the total number of 1 is: k+y-(x-k) =2*k+y-x

This can be discussed in three different situations:

1. A binary number with an odd number of 1 and a binary number with an odd number of 1: w is an even digit, so the x,y is odd, at which point the y-x result is even.

2. A binary number with an odd number of 1 and a binary number with an even number of 1: ibid., at this point x is odd, y is even, and the y-x result is odd.

3. A binary number with an even number of 1 and a binary number with an even number of 1: x is even, y is even, y-x is even or 0.


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.