The Power Of Two (more than 2^64)

Anonymous Coders

Problem:-
The range of numbre is greater than long long int that is greater than 2^64.
Therefore each digit of the number is stored in a character array terminating by ”.
How to find out,whether the number is a power of 2 or not?

Solution:-
This problem can be solved with little manipulation through the  Karnaugh Map and truth table.

See carefully the pattern of power of 2 and the number 1 lesser than power of 2 i.e.

23  = 1000      and 23 – 1 = 111                 bitwise and of    (1000) &(111) =…

24  = 10000      and 24 – 1 = 1111             bitwise and of     (10000) &(1111) =…
…………….. So on.

So we have to find the number just lesser than the given input and do AND operation of both numbers. If output of…

View original post 159 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s