Last active
December 4, 2016 13:49
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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