_ _int64

The _ _int64 keyword declares a new type, a 64-bit (8-byte) integer. As with the int, short, and long types, the _ _int64 type has a corresponding unsigned version, so the _ _int64 keyword actually can be used to create two types.

The following code sample shows how to declare two 64-bit integers, one signed and the other unsigned:

__int64            signed_big_int;
unsigned __int64   unsigned_big_int;

In the printf family of run-time library functions, the format for optional prefixes includes I64, in addition to F, N, h, l, and L. For example, the following statement includes an example of a valid format string:

printf("%I64d", x);

When manipulating 64-bit integers, no special functions are necessary. Ordinary arithmetic operators and operations behave as expected.

Note   Both the Alpha edition and the x86 edition of Visual C++ support the _ _int64 data type. However, the support in the Alpha edition is more complete; in particular, the integrated debugger recognizes _ _int64 variables in the Alpha edition but not in the x86 edition. Also, both editions provide full support for the _ _int8, _ _int16, and _ _int32 types. Use of these types is not recommended, except in situations where the program must interact with a fixed-byte layout (for example, in reading records previously stored on disk).

Use of _ _int64 should be conditional on the predefined macro _INTEGRAL_MAX_BITS. This macro describes the maximum size of integers defined using the form _ _intx. For example:

_#if defined (_INTEGRAL_MAX_BITS) && \
  _INTEGRAL_MAX_BITS >= 64
typedef signed __int64 int64;
typedef unsigned __int64 uint64;
#else
#error __int64 type not supported
#endif