The range here is circular, and the unsigned type of-1 is not 1, but 2 32-1. The reason for this is the following:
Firstly, the value range of unsigned int is 0 ~ (2
The range here is circular, and the unsigned type of-1 is not 1, but 2 32-1. The reason for this is the following:
Firstly, the value range of unsigned int is 0 ~ (2 32)-1.
When there is a symbol: ——————————
…… - 1 0 ……
When there is no symbol: ————————————
0 1 2 ………… | |
4294967294 4294967295(==- 1)
In other words,-1 was originally on the left of 0, which is the closest to 0 among integer negative numbers. But once the negative sign does not exist,-1 is left, and the unsigned value-1 is naturally the maximum value of unsigned int 4294967295.