Bitwise operators other than bitwise AND, bitwise, OR operator, can only be used to manipulate integers. Bit operations are purely bit-oriented.
1. Bitwise -and Operation
The operator of the bitwise-and operation is&, and the bitwise-to operation is: If two integer data aandb correspond to all 1 , the result bit is 1, otherwise 0. If the accuracy of the two operands is different, the result is the same precision as the operand with high precision.
2. Bitwise OR Operation
The operator for the bitwise OR operation is| ", the" bitwise OR "operation is: if the two operands correspond to 0 The result is 0 , otherwise the 1 . If the accuracy of the two operands is different, the result is the same precision as the operand with high precision.
3. Bitwise Inverse Operation
The bitwise negation operation is also called a bitwise NOT operation, and the operator is "~", which is a monocular operator. The bitwise negation operation is to modify 1 in the operand binary to 0and0 to 1.
4. Bitwise XOR Operator
^ 0 1 0 Span style= "font-family: ' Times New Roman ';" >1
5. the data can be shifted by bits. C # the following two types of shift operators are available. <<: Move left. >> move right.
ForX<<norX>>nthe operation of the form, meaning that thexmove left or rightNbit, the resulting type ofxsame. In this place,xcan only be of typeint,UINT,LongorULONG,Ncan only be of typeint, or the display is converted to one of these types, otherwise, a syntax error occurs when the program is compiled. When specifically executed, the left shift is the number of bits specified by the left-hand operand in-memory binary data to the right of the operand, and the empty portion of the right is 0. Moving right is a bit more complicated when using the ">>"symbol, if high0, left-shifted bits are entered0; If the highest bit is1, left-shifted bits are entered1.
The shift can achieve an integer divided by or multiplied by 2 of the n -th side effect.
This article is from the "Smile" blog, please be sure to keep this source http://yiyiweixiao.blog.51cto.com/2476874/1977466
42. My C # learning Note 8