Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What is the specific difference between unsigned short and int in C++?
What is the specific difference between unsigned short and int in C++?
First, one is a non-negative integer and the other is an integer. Unsigned can only get integers greater than or equal to 0.

Second, the ranges of the two values are different.

The basic data types in C and C++ languages are: char, integer (short, int, long), float, double?

At the same time, the types and shaping of characters can continue to be divided into signed and unsigned. By default, they are all signed. If you want to use unsigned, you can use it with unsigned description. If it is signed, the highest bit will indicate the sign bit, the highest bit is 0, indicating a positive number, and the highest bit is 1, indicating a negative number. Therefore, according to this, we can get different types of data ranges in signed and unsigned cases respectively: