 GFG App
Open App Browser
Continue

# Maximum value of long long int in C++

In this article, we will discuss the long long int data type in C++. long long int data type in C++ is used to store 64-bit integers. It is one of the largest data types to store integer values, unlike unsigned long long int both positive and negative.

Some properties of the long long int data type are:

• Being a signed data type, it can store positive values as well as negative values.
• Takes a size of 64 bits, where 1 bit is used to store the sign of the integer.
• A maximum integer value that can be stored in a long long int data type is typically 9, 223, 372, 036, 854, 775, 807 around 263 – 1(but is compiler dependent).
• The maximum value that can be stored in long long int is stored as a constant in <climits> header file. Whose value can be used as LLONG_MAX.
• A minimum integer value that can be stored in a long long int data type is typically –9, 223, 372, 036, 854, 775, 808, around –263  (but is compiler dependent).
• In case of overflow or underflow of data type, the value is wrapped around. For example, if –9, 223, 372, 036, 854, 775, 808 is stored in a long long int data type and 1 is subtracted from it, the value in that variable will become equal to 9, 223, 372, 036, 854, 775, 807. Similarly, in the case of overflow, the value will round back to –9, 223, 372, 036, 854, 775, 808.

Below is the program to get the highest value that can be stored in long long int in C++:

## C++

 `// C++ program to illustrate the maximum` `// value that can be stored in long long int` `#include ` `#include ` `using` `namespace` `std;`   `// Driver Code` `int` `main()` `{` `    ``// From the constant of climits` `    ``// header file` `    ``long` `long` `int` `valueFromLimits = LLONG_MAX;` `    ``cout << ``"Value from climits "` `         ``<< ``"constant (maximum): "``;` `    ``cout << valueFromLimits` `         ``<< ``"\n"``;`   `    ``valueFromLimits = LLONG_MIN;` `    ``cout << ``"Value from climits "` `         ``<< ``"constant (minimum): "``;` `    ``cout << valueFromLimits` `         ``<< ``"\n"``;`   `    ``return` `0;` `}`

Output:

```Value from climits constant (maximum): 9223372036854775807
Value from climits constant (minimum): -9223372036854775808```

Time Complexity: O(1)
Auxiliary Space: O(1)

My Personal Notes arrow_drop_up