consider the following code
-sharpinclude <stdio.h>
-sharpinclude <limits.h>
int compare (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
int main(void)
{
int a = 1;
int b = INT_MIN;
printf("%d %d\n", a,b);
printf("%d\n",compare((void *)&a,(void *)&b));
return 0;
}
output:
output is:
1-2147483648
-2147483647
I know that INT_MIN is-2147483648, and the negative number is one more than the integer, so INT_MAX is 2147483647. I searched for the subtraction of the complement on the Internet. Amurb = A + (- B), equals the complement of A plus the complement of (- B), but-B that is 2147483648 has exceeded the INT_MAX, so how is the subtraction carried out in this case?