> > 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.
Message
Re: logical shift operation
2009-06-27 by vietdung79