Which of these expressions will isolate the rightmost set bit?

a) x = x & (~x)
b) x = x ^ (~x)
c) x = x & (-x)
d) x = x ^ (-x)

1 thought on “Which of these expressions will isolate the rightmost set bit?”

  1. c
    Explanation: Negative of a number is stores as 2;s complement in C++, so when you will take AND of x and (-x) the rightmost digit will be preserved.

Leave a Comment