For example:
Char type is adopted, and a non-negative integer is represented by one byte. The minimum value is 0, and the maximum value cannot be 128.
Character type range:-128~ 127.
The range of unsigned character types is 0~255.
Extended data:
The char type accounts for 1 byte, which is 8 bits, and the storable positive integer is 01111,which is 127. If the int integer i= 128 is given to ch, overflow will occur.
Because 128 is an int type, accounting for 4 bytes, the binary code is 0000 0000 0000 00001000 0000. If assigned to a char variable with only 8 bits, only the lower 8 bits of 1000 0000 can be put in, and the rest will be deleted.
Integers are stored in the form of complement in the computer. At this time, 1000000 is a complement in the eyes of the computer, and the leftmost one is 1, indicating a negative number. Complement 1000000 corresponds to decimal system-128, so the final output is-128. So overflow will make the largest positive integer become the smallest negative integer.