偶校验算法

unsigned char Cal_parity(unsigned char rd) //产生偶校验
{
    rd = ((rd>>4)|(rd<<4))^rd;
    rd = (rd>>2)^rd;
    rd = (rd>>1)^rd;
    return rd&0x01;

}

具体原理参考自:http://hi.baidu.com/dikex/blog/item/eb139418b62f7c1a35fa413d.html

你可能感兴趣的:(c,算法)