how to test if a number is power of 2
Take its log and divide it by log(2) and if the result is a whole number(without fraction), then it is power of 2. Example:2,097,152. Is it a power of 2?:
Log(2,097,152)/Log(2)=21. Yes it is.