template<typename T>
struct Type {
static void print() {
std::cout << typeid(T).name() << ": range is ("
<< std::numeric_limits<T>::min() << ", "
<< std::numeric_limits<T>::max() << ")\n";
}
};
int main() {
Type<char>::print();
Type<short>::print();
Type<int>::print();
Type<long>::print();
Type<float>::print();
Type<double>::print();
Type<long double>::print(); // Some compilers will not handle this one well
Type<unsigned>::print();
system("pause");
return 0;
}
s: range is (-32768, 32767)
i: range is (-2147483648, 2147483647)
l: range is (-2147483648, 2147483647)
f: range is (1.17549e-038, 3.40282e+038)
d: range is (2.22507e-308, 1.79769e+308)
e: range is (0, 1.#INF)
j: range is (0, 4294967295)