Bitwise AND: how to solve
- Write the numbers in binary if they are not already shown that way. Bitwise AND compares numbers bit by bit.
- Line up the bits from right to left. If one number has fewer bits, add leading zeros so both strings have the same length.
- Apply the AND rule to each pair of bits:
1 AND 1 = 1
1 AND 0 = 0
0 AND 1 = 0
0 AND 0 = 0
So the result has a 1 only where both numbers have a 1 in the same position.
Helpful strategy
- Work from the least significant bit on the right.
- If the exercise gives decimal numbers, convert them to binary first, then do the bitwise AND.
- Keep the bits in the same positions; do not add or multiply the numbers.
Check your answer
- Re-read each column and verify that only matching
1 bits produced 1.
- If needed, convert the final binary answer back to decimal to see whether it matches the expected value.
- Make sure the answer is simplified to its final form, with no extra steps left unfinished.