See this code snippet
int main()
{
unsigned int a = 1000;
int b = -1;
if (a>b) printf(\"A is BIG! %d\\n\", a-b);
else printf(\"a is SMALL! %d\\n\", a
The hardware is designed to compare signed to signed and unsigned to unsigned.
If you want the arithmetic result, convert the unsigned value to a larger signed type first. Otherwise the compiler wil assume that the comparison is really between unsigned values.
And -1 is represented as 1111..1111, so it a very big quantity ... The biggest ... When interpreted as unsigned.