Confused using int type with bitwise operators and shifting in C

Viewed 35

Any thoughts on why I would get two different results, I suspect it has to do with a signed integer, but can't see the difference.

#include <stdio.h>

int main() {
    int x = 32;
    printf("%x\n", (~0 << x));
    printf("%x\n", (~0 << 32));
    return 0;
}

OUTPUT:

ffffffff
0

0 Answers
Related