The expression n & (n - 1) clears the lowest set bit of n.
Answer: B
Correct answer: True
Subtracting 1 turns the lowest set bit to 0 and every bit below it to 1, so ANDing with the original leaves that bit and all below it clear. Repeating the operation until n becomes 0 counts the set bits, which is Kernighan’s algorithm.
Please log in or register to report this question.