Information Storage and Retrieval
Pages
(Move to ...)
Home
About Me
▼
Saturday, August 16, 2014
Fastest way to know if a number is power of 2
Using Bitwise operators:
Check num & (num-1) == 0. If true, the number is a power of 2 else its not.
No comments:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment