ISO C and signed literal constants

c, constants, iso, literals

Solution

All non-suffixed decimal integer literals are signed, but they can not be negative. Perhaps non-negative is what you meant by "unsigned", but I think it's important to make a distinction -- they are not of an `unsigned int` type.

Once you've got a positive literal, the unary operator is applied. This is why `INT_MIN` is often defined as:

#define INT_MIN     (-2147483647 - 1)

Because you can't represent 2147483648 with a `signed int` on this platform.

Problem

I just started to read the ISO C 2011 standard , well the last public draft of it [1] , and realized that in the C Lexical Grammer [1][458ff.] all (literal) numerical constants are unsigned. Does that mean that the Compiler interpret a signed numerical constant (like -5.1E10 or -1) as a call of the corresponding unary-operator ? e.g -1 <=> -(1) , +512 <=> +(512) UPDATE: My fault, "all (literal) numerical constants are unsigned" I mean "all (literal) numerical constants are non-negative" Regard, Thomas

Original source