Possible Duplicate:
signed to unsigned conversion in C - is it always safe?
Let's say I declare a variable of type unsigned int : unsigned int x = -1;
Now -1 in two's complement (assuming 32 bit machine) is 0xFFFFFFFF. Now when I assigned this value to x, did the value 0x7FFFFFFF get assigned to x?
If it were so, then printf ("%d",x); would have printed the decimal equivalent of 0x7FFFFFFF, right? But, clearly this isn't happening, as the value that gets printed is -1. What am I missing here?
Edit: I know that we can use the %u format specifier to print unsigned values. But that doesn't help answer the question above.