Integer literal

Recognizing a string (sequence of characters in the source code) as an integer literal is part of the lexical analysis (lexing) phase, while evaluating the literal to its value is part of the semantic analysis phase.

For example, on recognizing the string 0x10 the lexer could immediately evaluate this to 16 and store that (a token of type integer and value 16), or defer evaluation and instead record a token of type integer and value 0x10.

This is particularly useful for bit fields and makes it easier to see the size of large numbers (such as a million) at a glance by subitizing rather than counting digits.

There can be some restrictions on placement; for example, in Java they cannot appear at the start or end of the literal, nor next to a decimal point.

Examples include: In C++14 (2014) and the next version of C as of 2022[update], C23, the apostrophe character may be used to separate digits arbitrarily in numeric literals.

However, this caused conflict with user-defined literals, so the apostrophe was proposed instead, as an "upper comma" (which is used in some other contexts).