What Is Long Long Data Type in C?


Angela Bailey

The long long data type in C is an extension of the long data type, which is used to store large integer values. It provides a larger range of values that can be represented compared to other integer data types.

Declaration and Size

To declare a variable of type long long, we use the keyword long long followed by the variable name. For example:

    long long number;

The size of the long long data type is implementation-dependent, but it is guaranteed to be at least 64 bits (8 bytes) on most modern systems. This means that it can store larger values than the int, short, and even regular long data types.

Ranges and Values

The range of values that can be stored in a long long variable depends on the underlying system’s architecture and the implementation of C language. However, on most systems, a long long can hold values between -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (inclusive).

Literals and Suffixes

To specify a literal value as a long long, we append either an uppercase or lowercase ‘L’ or ‘LL’ suffix to the value. For example:

    long long largeNumber = 1234567890LL;
    long long negativeNumber = -987654321LL;

It is important to include the suffix to ensure that the literal value is interpreted as a long long rather than a different data type.

Usage and Examples

The long long data type is commonly used when dealing with large numbers, such as in scientific calculations, financial applications, or when handling extremely large data sets.

Here’s an example that demonstrates the usage of long long:

#include <stdio.h>

int main() {
    long long population = 7800000000LL;
    printf("World population: %lld\n", population);
    return 0;

In this example, we declare a variable named population of type long long, and assign it the value of the current estimated world population. We then use the %lld format specifier to print the value of population. The output will be:

World population: 7800000000

Note on Portability

The use of the long long data type should be done with caution, as it may not be available on all systems or compilers. It is advisable to check the documentation or specifications of your Target system/compiler to ensure compatibility.

In Conclusion

The long long data type in C provides a larger range for storing integer values compared to other integer types. It is useful when dealing with large numbers and applications that require precision and accuracy. However, its usage should be handled carefully considering portability concerns.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy