Analyst Integration Question: Download Integration Programmer PDF

How to find if a number is power of two, without using arithmetic operator?

Tweet Share WhatsApp

Answer:

Assume its a question about using bitwise operator as soon as you hear restriction about not allowed to use arithmetic operator. If that restriction is not in place then you can easily check if a number is power of two by using modulus and division operator. By the using bitwise operator, there is a nice trick to do this. You can use following code to check if a number if power of two or no.

Download Integration Programmer PDF Read All 41 Integration Programmer Questions
Previous QuestionNext Question
Write an SQL query to find second highest salary in employee table?How to find a running Java process on UNIX?