On Wed, 26 Sep 2001, Andy Dougherty wrote:
[Spoiler below]
> On Wed, 26 Sep 2001, Hong Zhang wrote:
>
> > There should be no need. ~0xfff is singed int, which will be signed extended
> > by compilers as needed. Unless you are using a buggy compiler.
>
> Hehehe. Ok. Guess what the following will print:
>
> #include <stdio.h>
> int main(void) {
> int x = 511;
> printf("x = %x\n", x);
> printf("x & ~0xff = %x\n", x & (long long) ~0xff);
> return 0;
> }
Linux/x86:
x = 1ff
x & ~0xff = 100
Linux/Sparc, Solaris8/Sparc (both cc and gcc):
x = 1ff
x & ~0xff = 0
--
Andy Dougherty [EMAIL PROTECTED]
Dept. of Physics
Lafayette College, Easton PA 18042