Question.2
A developer implements an 8-bit left rotation:
uint8_t reg = 0xC5; uint8_t result = (reg << 3) | (reg >> 5);
He expects 0x2E. Does this code produce the correct result?
0x2E
Select Answer
Yes — the code is correct
No — reg << 3 is promoted to int, and bits above bit 7 leak into the OR, corrupting the result
No — the right shift discards the wrong bits
Yes — but only because the result is stored in a uint8_t, which truncates the promoted value