6.3.1.1
If an int can represent all values of the original type (as restricted by the width, for a bit-field), the value is converted to an int; otherwise, it is converted to an unsigned int. These are called the integer promotions.
所以这意味着如果我在表达式中使用 long int
,它将被降级为 unsigned int
?
最佳答案
您引用的位受其上方文本的限制:
The following may be used in an expression wherever an int or unsigned int may be used:
- An object or expression with an integer type whose integer conversion rank is less than the rank of int and unsigned int.
- A bit-field of type _Bool, int, signed int,or unsigned int.
If an int can represent all values of the original type, the value is converted to an int; otherwise, it is converted to an unsigned int. These are called the integer promotions. All other types are unchanged by the integer promotions.
换句话说,long int
不会被提升为 int
或 unsigned int
。
关于c - C 中的整数提升会降级 `long int` 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14994728/