%hu unsigned short integer %u unsigned long integer %lu unsigned long integer.
(2) To understand this problem, we need to know the storage form of integers in the computer first.
There are three ways to represent the number of symbols in a computer, namely, original code, complement and complement. These three representations have two parts: sign bit and digital bit. The sign bit is "positive" of 0 and "negative" of 1, while the digital bit has different representations.
The original code, complement and complement of positive numbers are the same;
The original code, complement and complement are all positive with the highest bit (sign bit) of the binary value being "0", and negative with the highest bit being "1".
In the mantissa (used to indicate the size of this number), the original code is the binary form of its absolute value, which is closest to the way of thinking of people. On the basis of the original code, the anti-code negates each bit (0 changes 1, 1 changes 0). Complement equals complement plus 1.
In computer systems, numerical values are always represented and stored by complement. The reason is that with the complement, the sign bit and numerical field can be handled uniformly; At the same time, addition and subtraction can also be handled in a unified way. In addition, the complementary code and the original code are converted to each other, and the operation process is the same, and no additional hardware circuit is needed.
(3) Because the integers in the computer are stored in complement.
Misreading will occur when signed negative numbers are output in U format. An error occurred when the computer interpreted the most significant sign bit "1" as a data bit.
For example, a 16-bit signed short integer with short a =-1; printf("%hu ",a); When the complement FFFF of a is interpreted as a positive number, it is equal to: 215+214+...+21+20 = 216-65438+.
A 32-bit signed integer, int b =-1; printf("%u ",b); When the complement form of b is FFFFFFFFF, it is interpreted as a positive number, so it is equal to: 2 31+2 30+...+21+2 0 = 2 32-1= 4 294 967 295.