Consider the expression -32768. The minus sign is the negation operator, not part of the literal. The decimal integer constant is 32768, and its type is selected before negation. Decimal integer constants are signed and use the first signed type that can represent their value. section 5.3
A boundary value
On a platform whose signed range ends at 32767, 32768 does not fit in signed int and is therefore signed long. Consequently, -32768 has signed long type; the smallest signed-int value cannot be written as one decimal literal preceded by a minus sign. section 5.3
Table 5.3. Examples for constants and their types. This is under the supposition that signed and unsigned have the commonly used representation with 32 bits (view table figure)
| Constant x |
Value |
Type |
Value of –x |
|---|---|---|---|
| 2147483647 | +2147483647 | signed | –2147483647 |
| 2147483648 | +2147483648 | signed long | –2147483648 |
| 4294967295 | +4294967295 | signed long | –4294967295 |
| 0x7FFFFFFF | +2147483647 | signed | –2147483647 |
| 0x80000000 | +2147483648 | unsigned | +2147483648 |
| 0xFFFFFFFF | +4294967295 | unsigned | +1 |
| 1 | +1 | signed | –1 |
| 1U | +1 | unsigned | +4294967295 |
Compare decimal and hexadecimal constants with their values, selected types, and the results of negation. section 5.3
