39. Bitwise Rotation and Counting-II

Question.6

A UART driver needs to compute the even parity bit for an 8-bit data byte before transmission. Even parity means the total number of 1-bits (data + parity) must be even. The developer writes:

uint8_t compute_parity(uint8_t data) {
   uint8_t parity = 0;
   uint8_t temp = data;
   while (temp) {
       parity ^= (temp & 1);
       temp >>= 1;
   }
   return ___;
}

What goes in the blank?

Need Help? Refer to the Quick Guide below

Select Answer