What is negative 32768 for 16-bit ints?
Posted on 2004-10-08
When testing a routine, I encountered the following that relates to this code:
int foo; // here int is 16-bits, of ranger -32768 to +32767
foo = =32768;
foo *= -1;
printf("foo is now %d\n", foo);
here, foo still is -32768: the value has not changed.
Now, I know you cannot have +32768 in the 16-bit world, but I'm trying to understand
what's happening here. When you multiply by -1, you are changing the SIGN BIT,
so how can the value remain the same?