Skip to content

Instantly share code, notes, and snippets.

@julianfrank
Last active December 4, 2016 13:49
Show Gist options
  • Save julianfrank/3d708e3b63d499e59fd6e028278d92aa to your computer and use it in GitHub Desktop.
Save julianfrank/3d708e3b63d499e59fd6e028278d92aa to your computer and use it in GitHub Desktop.
Function Returns the Next Power of 2 of the given number...Minimum Output is 2
function nextPow2(x) {
return Math.pow(2, Math.round(Math.max(x,0)).toString(2).length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment