Java-preliminary Understanding-Chapter III-Bitwise Operators

Source: Internet
Author: User
Tags bitwise bitwise operators logical operators

One. Bitwise operators

The bit here is the symbol of the bits, bit bit operation.

Viewing the PPT shows that there is more than one bitwise operator, which consists of several operators, even using the operation symbols previously defined.

Two. Analysis of different bit operators

A. & In addition to participation and computation, but also participate in bit operations, specific bit operation process: 6&3, it is important to remember that bit operation is to calculate the bits, 6 of the effective bits is 110, and 3 of the effective BITS is 011. & is used in the operation of the position, still has the function and operation. The logical operation of the binary number of the same position, 0 means that the false,1 represents true. 110&010=010, the conversion to 10 binary number is 2. Eventually, 6&3=2. Note : (1) 6 is actually an int type with a 32-bit binary number, but when the bitwise operation is performed, it is a valid bit, and the extra 0 bits are not involved in the operation. (2) & bit operation also has a feature, arbitrary enumeration of a two binary numbers between the & bit operation,

0111-0101-1010-0110

&0000-0000-0000-1111

As you can see, the result of this bitwise operation is to intercept the latter four bits of data. In special cases, the interception of data is also a feature of the & bit operation.

B. Similarly, the use of the bitwise operator is similar to the & bitwise operator. The bitwise operation is characterized by the ability to retain the valid bits of two binary digits, and 1 is a valid bit,

And the front said the effective bit is not a meaning.

C. ^ bit operation, ^ bit operation is characterized by preserving all, having a 1 position of data. A number XOR or bitwise operation is the same number two times. 6^3=5, 6^3^3=6.

The value has changed completely. If you convert to binary, the binary number is completely changed, which is equivalent to encryption.

In order to ensure the security of data, after encryption to restore data, the restored program is set in the USB drive, which is common in daily life.

Above these three, by borrowing logical operators to act as bitwise operators, a series of decimal results are obtained. But these results are not important,

It is important that computers use these mechanisms to do some other uses.

D. ~ Anti-code bit operation. The anti-code is-7. How to calculate the need to learn .

Java-preliminary Understanding-Chapter III-Bitwise Operators

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.