Skip to main content

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.

The long long data type in C is a standard integer type introduced in the C99 specification that guarantees a minimum storage width of 64 bits. It provides the largest standard integer capacity available in the language, strictly adhering to the hierarchical type constraint that sizeof(long long) >= sizeof(long) >= sizeof(int).

Syntax and Declarations

The type can be declared as signed or unsigned. By default, omitting the sign specifier results in a signed integer.
long long var1;                   // Implicitly signed 64-bit integer
signed long long var2;            // Explicitly signed 64-bit integer
unsigned long long var3;          // Unsigned 64-bit integer

Memory Footprint and Value Ranges

While the C standard dictates a minimum of 64 bits, on most modern architectures (both 32-bit and 64-bit systems), long long is exactly 64 bits (8 bytes). To accommodate ones’ complement and sign-magnitude architectures in C99 through C17, the standard guarantees the following minimum value ranges:
  • signed long long: (2631)-(2^{63}-1) to 26312^{63}-1
    • (-9,223,372,036,854,775,807 to 9,223,372,036,854,775,807)
    • Note: While C23 formally mandates two’s complement representation (extending the minimum to 263-2^{63}), the historical and strict C99 guaranteed minimum is (2631)-(2^{63}-1).
  • unsigned long long: 00 to 26412^{64}-1
    • (0 to 18,446,744,073,709,551,615)

Literal Suffixes

According to C standard rules for integer constants, an unsuffixed decimal literal automatically assumes the type long long int if its value cannot be represented by an int or long int. Suffixes are strictly required only when you want to explicitly force a smaller value to be typed as long long, or when you are writing an unsigned decimal constant that exceeds LLONG_MAX.
// Automatically typed as long long if it exceeds long capacity
long long auto_val = 9223372036854775807; 

// 'LL' or 'll' forces a smaller value to be signed long long
long long forced_signed = 42LL; 

// 'ULL', 'ull', 'Ull', or 'uLL' forces unsigned long long.
// Required for unsigned decimal literals > LLONG_MAX.
unsigned long long max_unsigned = 18446744073709551615ULL; 

Format Specifiers

To perform standard I/O operations (such as printf and scanf) with long long variables, you must use the ll (double-ell) length modifier combined with the appropriate conversion specifier.
long long s_val = -42LL;
unsigned long long u_val = 42ULL;

// Signed decimal
printf("%lld\n", s_val);  // or %lli

// Unsigned decimal
printf("%llu\n", u_val);

// Unsigned hexadecimal (lowercase / uppercase)
printf("%llx\n", u_val);
printf("%llX\n", u_val);

// Unsigned octal
printf("%llo\n", u_val);

Standard Library Limits

The <limits.h> header provides preprocessor macros that define the exact boundary values for long long types on the target compilation platform.
#include <limits.h>
#include <stdio.h>

int main() {
    printf("Min signed: %lld\n", LLONG_MIN);
    printf("Max signed: %lld\n", LLONG_MAX);
    printf("Max unsigned: %llu\n", ULLONG_MAX);
    
    return 0;
}
Master C with Deep Grasping Methodology!Learn More