Last active
December 21, 2015 15:37
-
-
Save leodutra/87edf2e92360c9797513 to your computer and use it in GitHub Desktop.
Fast fill bits from right - JavaScript bitwise function
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 fillBitsFromRight(n) { // http://jsperf.com/fill-bits-bitwise-vs-alternatives | |
return ~(-1 << n); // ~(~0 << n) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment