Skip to content

Instantly share code, notes, and snippets.

@cuixin
Created June 15, 2012 07:27
Show Gist options
  • Save cuixin/2935201 to your computer and use it in GitHub Desktop.
Save cuixin/2935201 to your computer and use it in GitHub Desktop.
是否是2的N次幂
public class Is2Power {
public static void main(String[] args) {
for (int i = 0;i <= 1024; i++) {
if ((i & -i) == i)
System.out.println(Integer.toBinaryString(i) + ", " + Integer.toBinaryString(-i) + " " + i);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment