Google
Information Storage and Retrieval: General Programming Concepts

Pages

Showing posts with label General Programming Concepts. Show all posts
Showing posts with label General Programming Concepts. Show all posts

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.