skip to content
Ivan's wiki
Site Tools
Search
Tools
Show pagesource
Backlinks
Recent Changes
Media Manager
Sitemap
>
Recent Changes
Media Manager
Sitemap
hpp-limits
This page is read only. You can view the source, but not change it.
# <limits> **[<limits>](https://en.cppreference.com/w/cpp/header/limits)** provides `std::numeric_limits<T>`, a traits class that gives you compile-time constants about numeric types: `std::numeric_limits<int>::max()`, `std::numeric_limits<float>::epsilon()`, etc. Use it to write generic code that adapts to the numeric type without hardcoding values. This example queries the maximum, minimum, and epsilon values for various numeric types at compile time. ```cpp // compile: g++ -std=c++11 -o limitsexample limitsexample.cpp // run: ./limitsexample // description: query numeric limits #include <limits> #include <iostream> int main() { std::cout << "int max: " << std::numeric_limits<int>::max() << "\n"; std::cout << "float epsilon: " << std::numeric_limits<float>::epsilon() << "\n"; std::cout << "double min: " << std::numeric_limits<double>::min() << "\n"; return 0; } ```
Page Tools
Show pagesource
Backlinks
Back to top