Bitwise in 1010 seconds.
Return 1
where both are 1
:
bin dec
---------
0001 1
&
0011 3
↓
0001 1
Return 1
where one or both are 1
:
bin dec
---------
0001 1
|
0011 3
↓↓
0011 3
Return 1
where either is 1
but not both are 1
:
bin dec
---------
0001 1
|
0011 3
↓
0010 2
Move bits n
positions to left:
bin dec
---------
0001 1
<<
0001 1
←
0010 2
Move bits n
positions to right:
bin dec
---------
0001 1
>>
0001 1
→
0000 0