re c1 = (unsigned char)i1>>2; I make a habit of coding as below to make operator precedence explicit: c1 = (unsigned char)(i1>>2); --- In AVR-Chat@yahoogroups.com, ÐнÑоÑенков Роман Ð'икÑоÑÐ¾Ð²Ð¸Ñ <djantoxa@...> wrote: > > Hello! > > Problem solved. It is my fault. > > >> i1 = 1024; > >> i2 = i1 >> 2; > >> c1 = (unsigned char)i1>>2; > >> > >> Why c1 = 0? Must be c1 = 256! > > i1 = 1023; ! > i2 = i1 >> 2; > c1 = (unsigned char)i1>>2; > c1 = 255 ! > -- > Best regards, > Roman Antoshchenkov > mailto:djantoxa@... >
Message
Re: logical shift operation
2009-06-27 by stevech11