Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C++

long long — a large signed integer type

long long is a built-in signed integer type with a width of at least 64 bits. It is useful for large counters and integer calculations, but its range is still finite, and overflowing signed arithmetic causes undefined behavior.

Version: C++23; repository compiler flag, production runtime not attested

Syntax

long long name = 0LL;

long long is the same type as long long int, signed long long, and signed long long int. Its width is at least 64 bits, covering at least −9223372036854775808 through 9223372036854775807. Do not assume it occupies exactly 8 bytes or is wider than long.

The suffix LL or ll on a decimal literal selects long long when the value fits that type; an example is 3'000'000'000LL. unsigned long long is a separate unsigned type, not another name for long long.

The destination variable's type does not automatically widen earlier calculations: assigning the product of two int values to long long does not prevent overflow in that multiplication. Use a sufficiently wide operand before the operation. Overflow of long long itself also causes undefined behavior, not guaranteed wrapping.

The example calculates total using long long and prints a predictable result. This entry targets C++23; the supplied site hosts an evolving working draft, not a frozen C++23 publication. A compiler flag does not attest production runtime behavior.

Examples

#include <iostream>

int main() {
    long long count = 3'000'000'000LL;
    long long total = count * 2LL;
    std::cout << total << '\n';
}

Result

6000000000

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources