Skip to content

Instantly share code, notes, and snippets.

@physacco
Created September 19, 2016 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save physacco/9ff4c9916eab43f3f7e87a0992f15e31 to your computer and use it in GitHub Desktop.
Save physacco/9ff4c9916eab43f3f7e87a0992f15e31 to your computer and use it in GitHub Desktop.
Example of std::numeric_limits.
#include <iostream>
#include <limits>
template <typename T>
void test_limits() {
T min = std::numeric_limits<T>::min();
T max = std::numeric_limits<T>::max();
std::cout << "min: " << min << std::endl;
std::cout << "max: " << max << std::endl;
}
int main() {
test_limits<int>();
test_limits<long>();
test_limits<float>();
test_limits<double>();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment