Subj : Re: bit shifting To : comp.programming From : Alex Fraser Date : Sun Aug 14 2005 04:17 pm "Rob Somers" wrote in message news:fJHLe.445$7R.20740@news20.bellglobal.com... > #include > > int main(void) > { > > 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 .