These days to see the algorithm into a bit operation because it is not used a little bit, someone should be the same as me.
This time I collected a few notes briefly, I hope we all add
The so-called bitwise operations are binary operations.
& If it is two people are very familiar with, "&&" is "with", one is also
is just two binary code "and", two are "1" will get "1"
00001001
&
00000101
=
00000001
All the others are "| |" Is "or", two as long as one is "1" will get "1"
00001001
|
00000101
=
00001101
This is not commonly used, "^" Two are "1" to "0", from one is "1" to "1"
00001001
^
00000101
=
00001100
>> << is displacement
How many digits to the left and right after the number is converted to binary
Cases:
14>>2=3
00001100 (14)
>>2
00000011 (3)
If it's gone, leave it.
3>>1=1
3>>2=0
00000011 (3)
>>1
00000001 (1)
"<<" is moving forward.
3<<2 = 14
00000011 (3)
<<2
00001100 (14)
This article is from the My database blog, so be sure to keep this source http://wyd51.blog.51cto.com/1549780/1793106
Bitwise operators & | ^ >> << Introduction