uint16_t a = 0x00 << 8 + 0xB9;
printf("%d",a);
I'm expecting 185
as an output but I'm getting 0
.
What is happening here?
uint16_t a = 0x00 << 8 + 0xB9;
printf("%d",a);
I'm expecting 185
as an output but I'm getting 0
.
What is happening here?
If you look at this link, you'll see that the order of precedence means that the addition is performed before the shift. Change your code to
uint16_t a = (0x00 << 8) + 0xB9;
printf("%d",a);
to see the desired behaviour.