Integer constants
suggest changeAn integer constant's prefix selects its base:
| Base | Prefix | Example |
|---|---|---|
| decimal | none | 345 |
| octal | 0 |
0531 |
| hexadecimal | 0x, 0X |
0x159 |
| binary (C23) | 0b, 0B |
0b101011001 |
A leading zero selects octal, so 010 has the value eight, not ten. The sign in -1 is a unary operator applied to the positive constant 1; it is not part of the token.
Common suffixes select candidate types:
| Suffix | Meaning |
|---|---|
u, U |
unsigned |
l, L |
long |
ll, LL |
long long |
Unsigned and length suffixes can be combined, as in 42UL or 42LLU. The implementation chooses the first type in the standard's candidate list that can represent the value; that list differs between decimal and nondecimal constants. Do not assume that every unsuffixed constant has type int.
C23 permits single quotes as digit separators, such as 1'000'000; they do not affect the value.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents