Skip to content

Instantly share code, notes, and snippets.

@seantunwin
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save seantunwin/2f092130c76e4de0c720 to your computer and use it in GitHub Desktop.

Select an option

Save seantunwin/2f092130c76e4de0c720 to your computer and use it in GitHub Desktop.
Easy power function (like Math.pow()) for positive exponents using the shift-left bitwise operator
// Where @var exponent is less than or equal to 1
// @return is @var num
function posPow(num, exponent) {
return num << ((exponent > 1) ? (exponent - 1) : 0 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment