Important note
I know that this question may seem too simple for you scientists; however, here is the best place that I know to post it.
Question
Suppose we have an int with all bits being 0, except for the last which is 11101000. How does my computer understand to return its two's complement i.e. -24 as value and not its original value i.e. 232?
Edit: Question Details
I have written the following simple C++ code which shows unsafe conversions:
int main()
{
double d = 1000;
{
int i = d;
char c = i;
cout << c;
}
}
The code returns -24 for c while the last byte of i which is the value of c is 11101000; Actually -24 is its two's complement, i.e. 00011000.