Secondary computer system

A binary operation

Binary data: 110101, to digital we saw was 53, the specific process:
a digital form that is 2 ^ n binary

Second, the binary bit operation

Binary left one, in fact, the numbers double.

Binary right one, it is the digital divide by two integer operations and seek providers.

Third, the bit operation in the java (the same for all languages ​​big like)

Wait decimal num- displaceable, m- bits to the right, with the result decimal shifted
leftward shifted
num << m
rightward shift (shift right logical)
num >>> m

Four, and arithmetic logical shift right

In the 32-bit binary system is 110101, for example decimal 53, as shown in presentation:

-53 is presented (complement bit positive number):

the 32-bit system, the right to the left is the number of 32-bit 0 is positive number 1 is negative.
Well, this time shift to the right, the question arises: for the sign bit (especially when the sign bit is 1), whether we need to do right? Therefore, Java defines two inside right, logical shift right and arithmetic shift right. A logical right shift, left up to 0.

Remain unchanged when the sign bit arithmetic right shift, except for a sign bit to the right and up a sign bit 1. 1 still make up the sign bit after.

>>> right to use logical representation, while using an arithmetic right shift >> representation in Java and Python languages.

Five-bit "or" "and" and "exclusive or"

"Or," "and" and "exclusive or" not much to do in this Figure should be interpreted understand.
Bit "or"

"and" bit

-bit "exclusive or"

Guess you like

Origin www.cnblogs.com/-Neo/p/12072486.html