Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get nearest upper power of two to current number
long NUP2(long x) {
x--;
for (int p=1; p<32; p<<=1) x |= (x >> p);
return ++x;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment