File: power_of_two.c

package info (click to toggle)
pd-lyonpotpourri 2.0%2Bgit20121009-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,176 kB
  • sloc: ansic: 18,330; makefile: 376
file content (17 lines) | stat: -rw-r--r-- 291 bytes parent folder | download | duplicates (3)
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;
}