Current location - Health Preservation Learning Network - Slimming men and women - Using int type to store 9999999999999999 can only store the value of 2 to the 32nd power-1, right?
Using int type to store 9999999999999999 can only store the value of 2 to the 32nd power-1, right?
If it is an unsigned 4-byte integer, only 2 32-1can be stored at most. If it is greater than this number, it will overflow. However, due to the difference of binary, it doesn't mean that everything greater than this limit is this limit. Let's take a smaller example.

Suppose a 4-bit binary number (0000 ~11,unsigned) can store 16 numbers from 0~ 15. If a 20:

The binary of 20 is 10 100 (note that it is a 5-bit binary). If you put four digits, the leftmost 1 will be thrown away because it can't fit. So what is actually stored is 0 100, which is decimal 4.