Recall & Review
beginner
What is bit manipulation?
Bit manipulation is the process of directly working with the individual bits of a number using operations like AND, OR, XOR, NOT, shifts, etc.
Click to reveal answer
beginner
Why is bit manipulation faster than arithmetic operations?
Bit manipulation uses simple CPU instructions that work directly on bits, which are faster and use less memory than arithmetic operations like multiplication or division.
Click to reveal answer
intermediate
When should you prefer bit manipulation over arithmetic?
Use bit manipulation when you need fast, low-level operations like checking flags, toggling bits, or multiplying/dividing by powers of two efficiently.
Click to reveal answer
beginner
How can you multiply a number by 2 using bit manipulation?
You can multiply by 2 by shifting the bits of the number one place to the left (number << 1).
Click to reveal answer
beginner
What is a common real-life analogy for bit manipulation?
Bit manipulation is like flipping switches on a control panel where each switch controls a specific feature or setting.
Click to reveal answer
Which bit operation can be used to check if a number is even or odd?
✗ Incorrect
AND with 1 checks the least significant bit; if it is 1, the number is odd, else even.
What does the bitwise left shift operator (<<) do to a number?
✗ Incorrect
Left shifting by 1 moves bits left, effectively multiplying the number by 2.
Why might bit manipulation be preferred in embedded systems?
✗ Incorrect
Bit manipulation is faster and uses less power, which is important in embedded systems with limited resources.
Which operation toggles a specific bit in a number?
✗ Incorrect
XOR with 1 flips the bit: if it was 0, it becomes 1; if 1, it becomes 0.
What is the result of (5 & 1) in bit manipulation?
✗ Incorrect
5 in binary is 0101; AND with 0001 gives 0001 which is 1.
Explain why bit manipulation can be faster than arithmetic operations and give an example.
Think about how CPUs handle bits versus numbers.
You got /3 concepts.
Describe a real-life scenario where bit manipulation is useful and why it is preferred.
Imagine controlling many on/off settings efficiently.
You got /3 concepts.