function s=parity_check(d)

% d must be a column vector of positive integers
% returns 1 if the number of ones in binary representation is odd
% and 0 if it's even

[f,e]=log2(max(d)); 
s=mod(sum(rem(floor(d*pow2(1-e:0)),2),2),2);