CKTIS / C++
Integer literals and their suffixes
An integer literal writes a value directly in code. Its base, value, and optional suffix determine its type; for `ULL`, `unsigned long long` is the only standard candidate.
Version: C++23; repository compiler flag, production runtime not attested
Syntax
digits [integer-suffix]; examples: 42, 42u, 42L, 42LL, 42ULL, 0x2A, 0b101010An integer literal contains digits and an optional suffix (integer literal suffix), without intervening whitespace. Notation is decimal, octal with leading 0, hexadecimal with 0x/0X, or binary with 0b/0B. Apostrophes between digits improve readability: 1'000 means 1000.
The type is the first type in the applicable list that holds the value. Unsuffixed decimal notation tries int, long, long long; other bases try int, unsigned int, long, unsigned long, long long, unsigned long long, in order.
The u/U suffix selects among unsigned int, unsigned long, unsigned long long. The l/L suffix starts at long, and ll/LL at long long; nondecimal bases also allow the corresponding unsigned alternatives. Combining U with L starts at unsigned long. For ULL, the sole standard candidate is unsigned long long. If the value does not fit in that type, the implementation may use a permitted extended unsigned integer type that can represent it.
Suffix components may appear in either order: 42ULL and 42LLU are equivalent. ll and LL are valid, but lL is not. A suffix does not truncate the value: if no permitted type, including any permitted extended type, can represent the value, the program is ill-formed.
Reference identifiers covered by this entry: unsigned suffix u/U, long/long long suffix l/L/ll/LL, ULL integer literal suffix.
Examples
#include <iostream>
#include <type_traits>
int main() {
constexpr auto count = 42u;
constexpr auto total = 42ULL;
static_assert(std::is_same_v<decltype(42u), unsigned int>);
static_assert(std::is_same_v<decltype(42ULL), unsigned long long>);
static_assert(0x2A == 0b101010 && 052 == 42);
std::cout << count << ' ' << total << '\n';
}
Result
42 42
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.