Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - (C language) Integer data overflow
(C language) Integer data overflow
In fact, this question is very simple, which may be related to your compilation environment. The range of int type is -32768-32767. So you can compare it to a circle. Because negative numbers are saved in the computer with complement, carry will appear after adding 1. If the char type means-128- 127, then char a = 128 will also become-128.

You can look at the picture below. This circle is like a range. If you don't believe me, you can try putting int a = 32769, and the output should become -32787.