Which of these expressions will return true if the input integer v is a power of two?

a) (v | (v + 1)) == 0;
b) (~v & (v – 1)) == 0;
c) (v | (v – 1)) == 0;
d) (v & (v – 1)) == 0;

1 thought on “Which of these expressions will return true if the input integer v is a power of two?”

Leave a Comment