I am reading the book C++ Primer, by Lippman and Lajoie. On page 65 they say: If we use both unsigned and int values in an arithmetic expression, the int value ordinarily is converted to unsigned.
If I try out their example, things work as expected, that is:
unsigned u = 10;
int i = -42;
std::cout << u + i << std::endl; // if 32-bit ints, prints 4294967264
However, if I change i to -10, the result I get is 0 instead of the expected 4294967296, with 32-bit ints:
unsigned u = 10;
int i = -10;
std::cout << u + i << std::endl; // prins 0 instead of 4294967296. Why?
Shouldn't this expression print 10 + (-10 mod 2^32) ?

