🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.Doubles n
  2. B.Clears the lowest set bit of n
  3. C.Sets every bit
  4. 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 →