69,369
社区成员
发帖
与我相关
我的任务
分享
Compute parity of word with a multiply
The following method computes the parity of the 32-bit value in only 8 operations using a multiply.
unsigned int v; // 32-bit word
v ^= v >> 1;
v ^= v >> 2;
v = (v & 0x11111111U) * 0x11111111U;
return (v >> 28) & 1;