Sail E0 Webinar
Question

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


Options:
A .  (v | (v + 1)) == 0;
B .  (~v & (v - 1)) == 0;
C .  (v | (v - 1)) == 0;
D .  (v & (v - 1)) == 0;
Answer: Option D

Power of two integers have a single set bit followed by unset bits.



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers