Table of Contents
Bitwise AND is the most commonly used logical Bitwise operator. It is represented by a sign (&).
AND operator is the same as the AND gate we studied in the chapter on digital electronics, as shown below:
What is the Bitwise AND operator?
The Bitwise AND operator is denoted by
&. When an AND gate is given with two inputs, the corresponding output will be:
- If two input bits are 1, the output is 1.
- In all other cases, it's 0. For example
- 1 & 0 => yields to 0.
- 0 & 1 => yields to 0.
- 0 & 0 => yields to 0.
a & b
AND compares each bit of the first operand to the second operand’s corresponding bit. If both bits are 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.
Gopi Gorantala Newsletter
Join the newsletter to receive the latest updates in your inbox.