adplus-dvertising
frame-decoration

Question

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;

Answer: (d).(v & (v – 1)) == 0;

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

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

Similar Questions

Discover Related MCQs

Q. Which of these expressions will make the rightmost set bit zero in an input integer x?

Q. Which of these expressions will isolate the rightmost set bit?

Q. 0946, 786427373824, ‘x’ and 0X2f are _____ _____ ____ and _____ literals respectively.

Q. Which of the following is not one of the sizes of the floating point types?

Q. Which of the following is a valid floating point literal?

Q. What is the range of the floating point numbers?

Q. Which of three sizes of floating point types should be used when extended precision is required?

Q. Which is used to indicate single precision value?

Q. The size of an object or a type can be determined using which operator?

Q. It is guaranteed that a ____ has atleast 8bits and a ____ has atleast 16 bits.

Q. Implementation dependent aspects about an implementation can be found in ____

Q. Size of C++ objects are expressed in terms of multiples of the size of a ____ and the size of a char is _______

Q. Identify the incorrect option.

Q. Which of the following will not return a value?

Q. ____ have the return type void?

Q. What does the following statement mean?
void a;

Q. Choose the incorrect option

Q. Identify the incorrect option.

Q. In which type does the enumerators are stored by the compiler?

Q. To which of these enumerators can be assigned?