Unsigned hexadecimal constant in C?

Amr Bekhit picture Amr Bekhit · Jan 19, 2011 · Viewed 30.6k times · Source

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

Answer

CB Bailey picture CB Bailey · Jan 19, 2011

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