wiki:hpp-limits
<limits>
<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.
Example
This example queries the maximum, minimum, and epsilon values for various numeric types at compile time.
// 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; }
wiki/hpp-limits.md · Last modified: by 127.0.0.1
