Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: logical shift operation

2009-06-27 by vietdung79

>
> Hello!
>
> I am coding in AVRStudio 4.16 and WinAVR-20090313
>
> Code:
> unsigned int i1 = 0;
> unsigned int i2 = 0;
> unsigned char c1 = 0;
>
> i1 = 1024;
> i2 = i1 >> 2;
> c1 = (unsigned char)i1>>2;
>
> Why c1 = 0? Must be c1 = 256!
>
> --
> Best regards,
> Roman Antoshchenkov
> mailto:djantoxa@...
>
c1 is a uchar so it can't be 256 (0x100). It is casted to 0.
If you want c1=256, you have to declare c1 as unsigned int.

Regards.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.