liveBook · Manning

Decimal integer constant

As explained in Modern C

A decimal integer constant is a C integer literal written using decimal digits and subject to the language's decimal type-selection rules.

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

How Modern C covers it

How deep it goes
Explains signedness, negation, first-fit selection, and boundary consequences, but defers broader integer-literal rules.
Examples
Uses -34, -32768, 32768, and 32-bit boundary examples to expose literal type selection.
What it assumes
Assumes familiarity with C literals and types while clarifying signedness and unary negation.
What you can do after
Evaluate decimal literals and predict their types and the effects of applying unary negation.
How it connects
Connects integer literals with signed types, the negation operator, and hexadecimal integer constants.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C. The section links point to the parts of the book it draws on.