Unsigned hexadecimal constant in C?

前端 未结 3 2107
难免孤独
难免孤独 2020-11-27 18:07

Does C treat hexadecimal constants (e.g. 0x23FE) and signed or unsigned int?

3条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 19:02

    The number itself is always interpreted as a non-negative number. Hexadecimal constants don't have a sign or any inherent way to express a negative number. The type of the constant is the first one of these which can represent their value:

    int
    unsigned int
    long int
    unsigned long int
    long long int
    unsigned long long int
    

提交回复
热议问题