Documentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
long long is a fundamental integral data type in C++ guaranteed by the standard to be at least 64 bits in width. Formalized in C++11, it provides the largest standard integer capacity natively available in the language, strictly superseding the minimum width guarantees of int (16 bits) and long (32 bits).
Memory and Range Specifications
According to the C++ standard, the exact size oflong long is implementation-defined but must contain at least 64 bits. Assuming a standard 64-bit implementation (where two’s complement representation is mandated since C++20):
signed long long: to ( to )unsigned long long: to ( to )
Syntax and Declarations
The type can be declared with or without theint keyword, and defaults to signed unless explicitly marked unsigned.
Literal Evaluation and Suffixes
The C++ standard dictates that the type of an unsuffixed decimal integer literal is determined by the compiler as the first type in which its value can fit from a fixed list:int, long int, or long long int. Therefore, a literal like 9223372036854775807 is evaluated as long long without requiring a suffix.
However, unsuffixed base-10 literals are never determined to be standard unsigned types. If a base-10 literal exceeds the maximum value of a signed long long, the compiler will first attempt to fit the literal into an extended signed integer type (such as __int128, if supported by the implementation). The program is strictly ill-formed if the value cannot be represented by any extended integer type. The ULL suffix is used to explicitly force evaluation as an unsigned long long and bypass this fallback behavior.
LL or ll for signed, ULL or ull for unsigned) are necessary in specific scenarios:
- Undefined Behavior and Overflow Prevention: To prevent intermediate issues before assignment. If operands are small enough to fit in an
int, the arithmetic is performed asint. Shifting anintby an amount greater than or equal to its bit-width results in Undefined Behavior (UB), and multiplying largeintvalues can result in arithmetic overflow. - Type Deduction: To force the
autokeyword to deduce a 64-bit type. - Overload Resolution: To explicitly match a function signature expecting a
long longparameter.
Programmatic Introspection
You can query the exact byte size and numeric limits oflong long on a specific architecture using the sizeof operator and the <limits> header. Note that sizeof returns the size in bytes, where a byte is defined by the standard as CHAR_BIT bits. Because CHAR_BIT can be greater than 8 on certain architectures (e.g., 16 or 32), sizeof(long long) is not guaranteed to be , even though the type itself is strictly guaranteed to be bits.
Relationship to Fixed-Width Integers
In modern C++ (via the<cstdint> header), int64_t and uint64_t provide exact 64-bit width guarantees. The underlying type used by the compiler to implement these typedefs depends on the platform’s data model.
On 32-bit systems and 64-bit Windows (which uses the LLP64 data model), long is 32 bits, making int64_t a typedef for long long int. However, on 64-bit Unix-like systems such as Linux and macOS (which use the LP64 data model), long is already 64 bits, meaning int64_t is typically a typedef for long int.
Master C++ with Deep Grasping Methodology!Learn More





