??? 03/24/06 16:22 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#112988 - And one more fast method Responding to: ???'s previous message |
These routines generate parity on 7-bit data returning a value ready for transmission (i.e., with the parity bit already in place).
unsigned char GenEvenParity(unsigned char b) { return (b ^ (((((b ^ ((b >> 4) | (b << 4))) + 0x41) & 0x82) + 0x7E) & 0x80)); } unsigned char GenOddParity(unsigned char b) { return (b ^ (((((b ^ ((b >> 4) | (b << 4))) + 0x41) & 0x82) + 0xFE) & 0x80)); } |