Add unsigned before the corresponding signed integer, that is, unsigned int, unsigned short, unsigned long and unsigned long long. Among them, unsigned int can be directly written as unsigned. } unsigned integers cannot store negative numbers, but the maximum value can be doubled. For example, the unsigned range is 0~232- 1.
The unsigned number only represents the size, and the highest bit of the signed number (in the case of binary, the highest bit represents the signed bit). Under the same operating system, the relationship between the maximum value of signed number and unsigned number is 2*x+ 1(x represents the maximum value of signed number, and 2*x+ 1 represents the maximum value of unsigned number). They represent the same data range, but the range is different.
Extended data
There are two types of integers: unsigned and signed. By default, all declared integer variables are signed types (char is a bit special). If you want to declare an unsigned type, you need to add the unsigned before the type.
The difference between an unsigned integer and a signed integer is that an unsigned type can store twice as many positive numbers as a signed integer, because a signed type stores most significant bit, while an unsigned type stores all numbers.
The difference between an unsigned integer and a signed integer is that an unsigned type can store twice as many positive numbers as a signed integer, because a signed type stores most significant bit, while an unsigned type stores all numbers. For example, in a 16 bit system, int can store data in the range of -32768~32767, while unsigned can store data in the range of 0~65535.
Baidu encyclopedia-unsigned integer