Subj : Re: bit shifting To : comp.programming From : Rob Somers Date : Sun Aug 14 2005 01:15 pm >> unsigned short x = 128; >> unsigned short y = 255; >> >> printf("%u\n", (unsigned short)(~x & y)); >> printf("%u\n", (unsigned short) ~x); >> >> return 0; >> } >> >> if 127 is 1111111 and 255 11111111, then &ing the two should give >> 01111111. > > Yes, but the above apparently computes 0xff7f & 0xff. > >> Why does the second printf() give 65407? > > What did you expect it to give? > > Alex Sorry, I was in a rush when I asked my question. I am not understanding what the difference between the 1111111 (127) and 01111111 (from 127 & 255) - obviously 1111111 is not 01111111, but I thought the leading 0 did not count for anything. .