Lecture 11 - Good programming practice
Lecture 11 - Good programming practice
A = 00000101 (5)
Bitwise AND operator. Output is 1 when both bits are 1,
& B = 00000011 (3)
otherwise output is 0.
A&B = 00000001 (1)
A = 00000101 (5)
Bitwise OR operator. Output is 1 when any or both bits are
| B = 00000011 (3)
1 otherwise output is 0.
A|B = 00000111 (7)
A = 00000101 (5)
Bitwise XOR operator. Output is 1 when both inputs are
^ B = 00000011 (3)
different and 0 when both inputs are same.
A^B = 00000110 (6)
Bitwise NOT operator. Compliments the bits, i.e., converts A = 00000101 (5)
~
1 to 0 and 0 to 1. ~A = 11111010 (-6)
Left shift operator. Shifts bits to left by a user defined A = 00000101 (5)
<<
bits. A<<1= 00001010 (10)