Open In App

Maximum value of unsigned long long int in C++

In this article, we will discuss the unsigned long long int data type in C++. It is the largest (64 bit) integer data type in C++

Some properties of the unsigned long long int data type are:



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




// C++ program to obtain the maximum
// value stored in unsigned long long int
#include <climits>
#include <iostream>
using namespace std;
  
// Driver Code
int main()
{
  
    // From the constant of climits
    // header file
    unsigned long long int valueFromLimits = ULLONG_MAX;
  
    cout << "Value from climits "
         << "constant: ";
    cout << valueFromLimits << "\n";
  
    // Using the wrap around property
    // of data types
  
    // Initialize a variable with value 0
    unsigned long long int value = 0;
  
    // Subtract 1 from value since an
    // unsigned data type cannot store
    // negative number, the value will
    // wrap around  and stores maximum
    // value stored in it
    value = value - 1;
    cout << "Value using the wrap"
         << " around property: "
         << value << "\n";
  
    return 0;
}

Output:

Value from climits constant: 18446744073709551615
Value using the wrap around property: 18446744073709551615

Article Tags :