liveBook · Manning

Literal suffix

As explained in Modern C, Third Edition

A literal suffix is a letter or letter sequence appended to a C literal to constrain or select its type.

A literal suffix is a letter sequence appended to a C literal to constrain its type. For example, 1 has type signed int, 1U has type unsigned, 1L has type signed long, and 1ULL has type unsigned long long; each represents the value 1. section 5.3

Choosing an integer type

Use l or L to require at least long, ll or LL to require long long, and u or U to force unsigned. Thus 1U selects unsigned, while 1ULL selects unsigned long long. For prefixed literals such as 0xFFFF'FFFF, the base and suffix jointly affect the deduced type; assumptions about signed representations are not universally portable. section 5.3

Table 5.4 Suffixes for integer literals and their types
Suffix Type
l   or  L At least long
ll or  LL long long
wb or  WB _BitInt(𝑁) for sufficiently large 𝑁
u   or  U Force unsigned

Compare the available integer suffixes, their minimum rank, signedness effect, and C23 bit-precise typing. section 5.3

How Modern C, Third Edition covers it

How deep it goes
Explains suffix rules through examples and portability constraints, including C23 bit-precise suffixes, but defers their later type details.
Examples
Uses 1, 1U, 1L, 1ULL, hexadecimal literals, and a suffix table to compare values and types.
What it assumes
Assumes familiarity with C literals and integer types while establishing how bases and suffixes influence deduced types.
What you can do after
Apply integer suffixes to request minimum rank or unsigned and bit-precise types while recognizing representation-dependent assumptions.
How it connects
Links integer literals with numeric bases, integer types, signedness, rank, and bit-precise types.

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.