Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

unsigned long long type

unsigned long long is an unsigned integer type with at least 64 value bits and modular arithmetic.

Version: C23; repository compiler flag, production runtime not attested

Syntax

unsigned long long name = 0ULL;

unsigned long long (also unsigned long long int) is a standard unsigned integer type. Its range is 0 through ULLONG_MAX from <limits.h>; that maximum is at least 18446744073709551615. Do not assume exactly 64 bits or an 8-byte size.

Arithmetic in this type is modulo ULLONG_MAX + 1 (mathematically): adding 1ULL to the maximum produces 0. An integer constant with the ULL suffix, such as 0ULL or 1ULL, has type unsigned long long if its value does not exceed ULLONG_MAX. If it does, the constant may have an extended unsigned integer type if one can represent the value. To print an unsigned long long value, printf uses %llu. The example demonstrates defined wraparound, but accidental wraparound can still be a program bug.

Examples

#include <limits.h>
#include <stdio.h>

int main(void)
{
    unsigned long long value = ULLONG_MAX;
    value += 1ULL;
    printf("%llu\n", value);
    return 0;
}

Result

0

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