From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ingo Krabbe To: Ben Kohlen Cc: Subject: Re: bug? Date: Sun, 17 Jun 2001 02:55:00 -0000 Message-id: References: <20010615225730.76865.qmail@web11001.mail.yahoo.com> X-SW-Source: 2001-06/msg00121.html On Fri, 15 Jun 2001, Ben Kohlen wrote: > I am expecting that when I shift right, I will always > get zeroes in from the left, but when I use data types > less than 32 bits, this is not always the case. > > Example: > ... > unsigned short s = 0xcc55; > printf("%x\n", (s<<8)>>8); > ... > yeilds the output "cc55" where as I was expecting > "55". > I don't think thats a bug, it is more a question of flavour, of course it would be very nice to fill 0 into the upper bits. It may be better to mask them out: #define CLEAR_UPPER_BITS(n,x) \ ((n