+0  
 
0
450
1
avatar

how to test if a number is power of 2

 Apr 11, 2016
 #1
avatar
0

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.

 Apr 11, 2016

0 Online Users