Skip to content

Instantly share code, notes, and snippets.

@normanmaurer
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save normanmaurer/9322333 to your computer and use it in GitHub Desktop.

Select an option

Save normanmaurer/9322333 to your computer and use it in GitHub Desktop.
private static int index(int val) {
int res = 0;
while (val > 1) {
val >>= 1;
res++;
}
return res;
}
System.out.println(8192 + " "+ index(8192 >> 13));
System.out.println(16384 + " "+ index(16384 >> 13));
System.out.println(32768 + " "+ index(32768 >> 13));
8192 0
16384 1
32768 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment