INT64 Data Type

Windows API Reference - Basic Types

Description

The INT64 data type is a signed 64-bit integer. It is used to represent whole numbers that can range from approximately -9 quintillion to +9 quintillion. This type is fundamental for handling large numerical values, timestamps, or any data that requires a wide range of representation for integers.

Syntax

typedef __int64 INT64;

Details

In Windows programming, INT64 is an alias for the C/C++ built-in type __int64. This type guarantees a minimum range of -263 to 263 - 1.

Platform Support

INT64 is supported across all modern Windows operating systems and architectures, including 32-bit and 64-bit environments.

Use Cases

Example

The following C++ snippet demonstrates the declaration and usage of an INT64 variable:

#include <iostream>
#include <cstdint> // For INT64 definition in modern C++

int main() {
    // Using the typedef from Windows headers, or C++20's std::int64_t
    // If using older C++ or just Windows headers:
    // typedef long long INT64; // In many compilers, long long is equivalent

    // For clarity and cross-platform compatibility, std::int64_t is preferred in C++
    std::int64_t largeNumber = 9223372036854775807LL; // Maximum value for signed 64-bit integer
    std::int64_t negativeNumber = -123456789012345678LL;

    std::cout << "A large positive number: " << largeNumber << std::endl;
    std::cout << "A large negative number: " << negativeNumber << std::endl;

    // Example of a calculation that might overflow a 32-bit integer
    std::int64_t product = 3000000000LL * 3LL;
    std::cout << "Product: " << product << std::endl;

    return 0;
}

Related Information

Note: In C++11 and later, the standard library provides <cstdint>, which defines fixed-width integer types like std::int64_t. This is generally the preferred and more portable way to declare 64-bit integers in modern C++ code, as it is guaranteed to be a signed 64-bit integer regardless of the compiler or platform. However, INT64 remains prevalent in older Windows API codebases.