C++ Int Minimum Value

In C++, an int is a commonly used data type to store integer values. The size of an int is typically 32 bits on modern systems, and the minimum value it can represent is -2,147,483,648. This value is defined by the INT_MIN macro in the <climits> header.


Minimum Limit of Int

The int data type represents numbers in the range:

  • Minimum Value: -2,147,483,648
  • Maximum Value: 2,147,483,647

The range is derived from the formula:

-2^(n-1) to 2^(n-1) - 1

Where n is the number of bits used by the data type. For an int, n = 32, resulting in:

-2^(32-1) to 2^(32-1) - 1 = -2,147,483,648 to 2,147,483,647

C++ Program to Access Int Minimum Value

You can programmatically access the minimum value of an int using the INT_MIN constant from the <climits> header.

In the following program, we will see how to access and use the minimum value of an int.

main.cpp

</>
Copy
#include <iostream>
#include <climits>

int main() {
    // Accessing the minimum value of int
    std::cout << "The minimum value of int is: " << INT_MIN << std::endl;
    return 0;
}

Output

The minimum value of int is: -2147483648

Explanation

  • The <climits> header provides macros for the limits of fundamental data types in C++.
  • The INT_MIN macro defines the minimum value of an int, which is -2,147,483,648 for a 32-bit integer.
  • The program uses std::cout to output the minimum value of an int directly using INT_MIN.