home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / ISPOW2.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  326b  |  23 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. #include <stdio.h>
  4. #include "snipmath.h"
  5.  
  6. int ispow2(int x)
  7. {
  8.       return! ((~(~0U>>1)|x)&x -1) ;
  9. }
  10.  
  11. #ifdef TEST
  12.  
  13. int main(void)
  14. {
  15.       int i;
  16.  
  17.       for (i = 0; i < 256; ++i)
  18.             printf("%3d: %d\n", i, ispow2(i));
  19.       return 0;
  20. }
  21.  
  22. #endif /* TEST */
  23.