类似地,当一个小整数(char、short、int)被传递给 printf (3) 时,它会扩展成 64 位的,符号会适当地进行扩展。
Similarly, when a small integer (char, short, int) is passed into printf (3), it will be widened to 64-bits and the sign will be extended if appropriate.
确保使用无符号整数来防止符号扩展的问题。
Ensure that an unsigned int is used where appropriate to prevent sign extension.
扩展转换的一个例子是将32位有符号整数值转换为64位有符号整数值。
An example of a widening conversion is converting a value that is a 32-bit signed integer to a value that is a 64-bit signed integer.
应用推荐