Last active
July 17, 2018 11:43
-
-
Save e-mihaylin/0198d52cd92d64bae344345368d8b151 to your computer and use it in GitHub Desktop.
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
const hammingWeight = v => { | |
v = v - (v>>1 & 0x55555555); | |
v = (v & 0x33333333) + (v>>2 & 0x33333333); | |
return ((v + (v>>4) & 0xF0F0F0F) * 0x1010101) >> 24; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment