---
title: 1.20 Numeric Limits
description: "Each fundamental data type can store values only within a specific range. The `` header provides information about these ranges through the `std::numeric_limits` class template. This example demonstrates how to determine the minimum and maximum values that can be stored…"
url: "https://edcret.in/docs/cpp-programming/basic-refreshers-cplusplus/1-20-numeric-limits/"
updated: "2026-07-28"
category: C++ Programming / Basic Refreshers
---

# 1.20 Numeric Limits

Each fundamental data type can store values only within a specific range. The `<limits>` header provides information about these ranges through the `std::numeric_limits` class template.

This example demonstrates how to determine the minimum and maximum values that can be stored by commonly used numeric data types.

## Source Code

```
#include <iostream>
#include <limits>

int main()
{
    std::cout << "int\n";
    std::cout << "Minimum: " << std::numeric_limits<int>::min() << '\n';
    std::cout << "Maximum: " << std::numeric_limits<int>::max() << "\n\n";

    std::cout << "float\n";
    std::cout << "Minimum: " << std::numeric_limits<float>::lowest() << '\n';
    std::cout << "Maximum: " << std::numeric_limits<float>::max() << '\n';

    return 0;
}
```

## Output

```
int
Minimum: -2147483648
Maximum: 2147483647

float
Minimum: -3.40282e+38
Maximum: 3.40282e+38
```

> The reported values are implementation-dependent and may vary depending on the compiler and target platform.

## Explanation

- `#include <limits>` includes the Standard Library header that defines the `std::numeric_limits` class template.
- `std::numeric_limits<int>::min()` returns the smallest value that can be represented by the `int` type.
- `std::numeric_limits<int>::max()` returns the largest value that can be represented by the `int` type.
- `std::numeric_limits<float>::lowest()` returns the lowest finite value that can be represented by the `float` type.
- `std::numeric_limits<float>::max()` returns the largest finite value that can be represented by the `float` type.
- `std::numeric_limits` provides similar information for most fundamental arithmetic types, including `char`, `short`, `long`, `double`, and `bool`.
- `return 0;` terminates the program successfully.
