LONGLONG
Syntax
typedef __int64 LONGLONG;
Description
The LONGLONG type is a signed 64-bit integer. It is equivalent to the __int64 type in Microsoft C/C++.
This type is used to represent signed integer values that can range from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
Range
The range of values for LONGLONG is:
- Minimum value:
-9,223,372,036,854,775,808LL - Maximum value:
9,223,372,036,854,775,807LL
The LL suffix is used to specify a 64-bit literal.
Usage
The LONGLONG type is commonly used in scenarios where large integer values need to be stored, such as:
- File sizes and offsets
- Timestamps (e.g., FILETIME)
- Large counters or accumulators
- Interoperability with 64-bit systems or libraries
Example
The following code snippet demonstrates the declaration and usage of a LONGLONG variable:
#include <stdio.h>
int main() {
LONGLONG largeNumber = 1234567890123456789LL;
LONGLONG negativeNumber = -9876543210987654321LL;
printf("Large number: %lld\n", largeNumber);
printf("Negative number: %lld\n", negativeNumber);
if (largeNumber > 0) {
printf("The large number is positive.\n");
}
return 0;
}
Note
When printing LONGLONG values using printf, use the %lld format specifier. For scanf, use %lld.
Related Types
ULONGLONG: An unsigned 64-bit integer.INT64: An alias forLONGLONG, commonly used in older Microsoft SDKs.