Related Articles

# Maximum value of long long int in C++

• Difficulty Level : Basic
• Last Updated : 18 Dec, 2020

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 as well as 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 an 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
```
Want to learn from the best curated videos and practice problems, check out the C++ Foundation Course for Basic to Advanced C++ and C++ STL Course for the language and STL. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
My Personal Notes arrow_drop_up