isParity function
Calculate parity of an arbitrary length integer.
Implementation
bool isParity(int value) {
// Algorithm for counting set bits taken from LLVM optimization proposal at:
// https://llvm.org/bugs/show_bug.cgi?id=1488
var count = 0;
for (var v = value; v != 0; count++) {
v &= v - 1; // clear the least significant bit set
}
return count % 2 == 0;
}