|
-
October 25th, 2007, 11:31 PM
#1
Simplest way to find power of number...
Hi GURUs,
I want to be able to find out whether a specific number is 2^x or not.
For example:
64 --> yes, it is a 2^6
32 --> yes, it is a 2^5
24 --> no, because it is not part of 2 power of x.
8 --> yes, because it is 2^3
6 --> no, because it is not a 2 power of x.
My question is, given a specific a number, how to determine if it is a 2^x value or not?
I know the hard way which is do a loop until the value we want to find is greater than 2^x.
Is there a more simple way to do it?
Cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|