To check if
some number is a power of two there many methods available but there is an efficient one to do this.
First of all assure that the number is not (because zero is not some power of two).
Then assure if the (number - 1) and number's logical and is zero.
Let's take a look what is happening behind this logical and operator.
You may run it for any power of two.
Subscribe to:
Post Comments
(
Atom
)
(y)
ReplyDelete