aboutsummaryrefslogtreecommitdiff
path: root/lib/power_of_two.c
blob: 038c6a3265e23cb5c13b24e55c079479c484a8c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

int power_of_two(int test)
{
  int limit = 8192;
  int compare = 1;
  //  post("testing what we thing is an int:%d",test);
  do {
    if(test == compare){
      //      post("good power of 2 found!");
      return 1;
    } 
    compare *= 2;
  } while (compare <= limit);
  
  return 0;
}