|
Boost Users : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-12-18 14:10:52
Daryle Walker wrote:
> On 12/16/05 2:03 PM, "Clarke, Trevor" <tclarke_at_[hidden]> 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.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net