Question.2
A developer wants to swap the upper and lower nibbles of an 8-bit register. The register currently holds 0xA7. He writes:
0xA7
uint8_t result = (reg << 4) | (reg >> 4);
Will this produce the correct result 0x7A?
0x7A
Select Answer
Yes — this method always correctly swaps the nibbles
No — integer promotion causes extra bits in the upper byte
No — the shifts destroy the nibble values
Yes, because the final assignment to uint8_t