18 Dec
2005
18 Dec
'05
7:10 p.m.
Daryle Walker wrote:
On 12/16/05 2:03 PM, "Clarke, Trevor"
wrote: It's not a mask to stop data loss but to tell VS you want the data loss. I.E.
unsigned short a = 0x1234; return (a << 8) & 0xffff; [TRUNCATE past message context]
That mask retains 100% of the bits (if a "short" is 16 bits), so it effectively does nothing. That's a waste of cycles if the masking isn't optimized away. I don't get how this shuts up the RTC unless this construct was specifically created as a workaround.
There is no unsigned short arithmetic in C/C++; in a << 8 a is promoted to int or unsigned int first, then the result is implicitly converted to unsigned short by the return, and this causes high-order bits to be lost.