Skip to content

Instantly share code, notes, and snippets.

@ahmadyan
Created May 8, 2016 21:28
Show Gist options
  • Save ahmadyan/c3203392b3ac8104eb8ec4d47958bfa4 to your computer and use it in GitHub Desktop.
Save ahmadyan/c3203392b3ac8104eb8ec4d47958bfa4 to your computer and use it in GitHub Desktop.
size_t count() const
{ // count number of set bits
static char _Bitsperhex[] = "\0\1\1\2\1\2\2\3\1\2\2\3\2\3\3\4";
size_t _Val = 0;
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
for (_Ty _Wordval = _Array[_Wpos]; _Wordval != 0; _Wordval >>= 4)
_Val += _Bitsperhex[_Wordval & 0xF];
return (_Val);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment