In <3f856d52$0$32136$ lekom.at> "Robert Stankowic" <> writes:
>"pete" <> schrieb im Newsbeitrag
>news:...
>> Jannick wrote:
>> >
>> > Hi I have:
>> > unsigned int myvalue=0;
>> > unsigned char mytest=0;
>> >
>> > mytest=0x34;
>> > myvalue = mytest<<24;
>> >
>> > Then myvalue gets the value 0x1A000000!!!!!
>> > How is this possible? Should'nt it be 0x34000000???
>>
>> I guess we're all assuming that the width of unsigned,
>> is at least 25 bits.
>> Is it, on your system ?
>
>Well, if myvalue becomes 0x1A000000 we can assume that, can we?
We can safely assume 29 bits. Which makes a minimum of 32 bits a
reasonable assumption. Pete should have engaged his brain before posting.
>And besides that, even if the width would be less than 24 the result would
>be well defined and definitely not 0x1a000000
>If I am not mistaken
>on all sizes up to and including 26 bits the value would be 0x0,
>27 and 28 bits will give 0x4000000,
>29 bits 0x14000000,
>30 bits and above 0x34000000
Wrong.
If the value of the right operand is negative or is greater than or
equal to the width in bits of the promoted left operand, the behavior
is undefined.
There was a long thread on this issue in comp.std.c, a few weeks ago.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: