← Bit Manipulation Quiz: all 8 questions
Bit Manipulation Quiz · Question 5 of 8
What does n & (n − 1) do?
What does n & (n − 1) do?
- A.Doubles n
- B.Clears the lowest set bit of n
- C.Sets every bit
- D.Reverses the bits
Answer & explanation
Correct answer: Clears the lowest set bit of n
Subtracting 1 flips the lowest 1 and the 0s after it; AND keeps everything else.
Can you get the rest right without peeking?
Take the timed Bit Manipulation Quiz quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →