C has different rules for decimal, octal and hexadecimal constants.
For decimal, it is the first type the value can fit in: int
, long
, long long
For hexadecimal, it is the first type the value can fit in: int
, unsigned int
, long
, unsigned long
, long long
, unsigned long long
For example on a system with 32-bit
int
and unsigned int
: 0x80000000
is unsigned int
.
Note that for decimal constants, C90 had different rules (but rules didn't change for hexadecimal constants).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…