O'Reilly logo
  • Chris Kang thinks this is interesting:

If we assign a value outside this range, the compiler assigns the remainder of that value modulo 256. Therefore, assigning –1 to an 8-bit unsigned char gives that object the value 255.

From

Cover of C++ Primer, Fifth Edition

Note

The value which is applied to modulo 256 is the value represented by the binary number. So, -1 is 255 in binary representation. So, 255 mod 256 is 255.