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;
I got this question in an international level competition.
The query is from Integer Types topic in portion Types, Pointers, Arrays & Structures in C++ of C++