liveBook · Manning

Decimal literal

As explained in Modern C, Third Edition

A decimal integer literal is a C integer literal written using decimal digits without a nondecimal base prefix.

A decimal integer literal writes a whole-number constant with ordinary decimal digits and no nondecimal base prefix. For example, 123 denotes the value 123. section 5.3

A decimal constant in code

int count = 123; Here, 123 supplies the integer value assigned to count. Compare 077 for octal, 0xFFFF for hexadecimal, and 0b1010 for binary notation; binary literals were introduced in C23. section 5.3

Table 5.3 Examples for literals and their types, under the supposition that signed and unsigned have the commonly used representation with 32 bits
Literal 𝑥 Value Type Value of -𝑥
2'147'483'647 +2,147,483,647 signed -2,147,483,647
2'147'483'648 +2,147,483,648 signed long -2,147,483,648
4'294'967'295 +4,294,967,295 signed long -4,294,967,295
0x7FFF'FFFF +2,147,483,647 signed -2,147,483,647
0x8000'0000 +2,147,483,648 unsigned +2,147,483,648
0xFFFF'FFFF +4,294,967,295 unsigned +1
1 +1 signed -1
1U +1 unsigned +4,294,967,295

Compare representative literal values and inferred types, including decimal boundary cases and hexadecimal notation. section 5.3

How Modern C, Third Edition covers it

How deep it goes
Defines decimal notation and contrasts its base prefixes with octal, hexadecimal, binary, and floating-point forms.
Examples
Uses 123 as decimal, 077 as octal, 0xFFFF as hexadecimal, and 0b1010 as binary examples.
What you can do after
Apply it via C syntax to write ordinary whole-number constants and distinguish them from other literal forms.
How it connects
Connects decimal integer literals with octal, hexadecimal, binary, floating-point, and character literals.

Related concepts

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