Skip to content

Instantly share code, notes, and snippets.

@polaris
Last active October 10, 2017 17:20
Show Gist options
  • Save polaris/ad4571f9d192388470123a518462fb41 to your computer and use it in GitHub Desktop.
Save polaris/ad4571f9d192388470123a518462fb41 to your computer and use it in GitHub Desktop.
Compute the parity of a word
short parity(unsigned long x) {
short result = 0;
while (x) {
result ^= 1
x &= (x - 1);
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment