For example the code below
int a = -7777;
int b = 10;
cout<< a % b<<endl;
cout<<(a+b)%b<<endl;
cout<< -7777%10 <<endl;
The results are:
-7
-7
-7
but if I changed the type of b to unsigned int, it has different values;
int a = -7777;
unsigned int b = 10;
cout<< a % b<<endl;
cout<<(a+b)%b<<endl;
cout<< -7777%10 <<endl;
The resutls are
9
9
-7
Could any body advise how it is working here? How do the differences come?
Btw: I am using C++ in Xcode latest version.