CKTIS / C++
std::uint64_t — 64-bit unsigned integer
std::uint64_t from <cstdint> is an optional alias for an unsigned integer type with exactly 64 bits and no padding bits. It stores values from 0 through 18446744073709551615.
Version: C++23; repository compiler flag, production runtime not attested
Syntax
#include <cstdint>
std::uint64_t name{value};std::uint64_t is an alias for an existing type, not a separate new type. Include <cstdint> and declare variables as std::uint64_t name{value};. Its exact width is useful when a data format requires 64-bit nonnegative values.
The type is optional: an implementation provides it if it has a suitable type with exactly 64 bits and no padding bits. The macro UINT64_MAX is available when this alias exists. Do not assume that the alias always denotes unsigned long long.
The range is 0 through 18446744073709551615, or 2^64 − 1. Arithmetic performed in std::uint64_t works modulo 2^64, but integer promotions can change the type in which an operation is performed. If std::uint64_t promotes to int and INT_MAX equals UINT64_MAX, directly incrementing the maximum value overflows signed int, which is undefined behavior. Even when wrapping to zero is well-defined, it can indicate a program logic error. Exact width does not specify byte order for binary storage.
The example prints the maximum, converts value to unsigned long long, adds 1ULL, and converts the result back to std::uint64_t. The addition is unsigned, and the conversion back yields the result modulo 2^64, so the example prints 0. The #ifndef UINT64_MAX condition provides a clear error on implementations without this optional type. The supplied source is an evolving standard draft, not a frozen C++23 edition.
Examples
#include <cstdint>
#include <iostream>
#ifndef UINT64_MAX
#error "This example requires std::uint64_t"
#else
int main() {
std::uint64_t value{UINT64_MAX};
std::cout << static_cast<unsigned long long>(value) << '\n';
value = static_cast<std::uint64_t>(static_cast<unsigned long long>(value) + 1ULL);
std::cout << static_cast<unsigned long long>(value) << '\n';
}
#endif
Result
18446744073709551615 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.