Created
September 19, 2016 11:33
-
-
Save physacco/9ff4c9916eab43f3f7e87a0992f15e31 to your computer and use it in GitHub Desktop.
Example of std::numeric_limits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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