[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppNumeric_Limits
An alternative is boost::numeric::bounds.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppNumeric_Limits
(C++) std::numeric_limits
To find the limits of datatypes at compile time.template <class T> void coutRange() { std::cout << static_cast<int>(std::numeric_limits<T>::min()) << " to " << static_cast<int>(std::numeric_limits<T>::max()) << "\n"; } int main() { std::cout << "Char has range: "; coutRange<char>(); std::cout << "Unsigned char has range: "; coutRange<unsigned char>(); std::cout << "Short has range: "; coutRange<short>(); std::cout << "Int has range: "; coutRange<int>(); }
- include <iostream>
An alternative is boost::numeric::bounds.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
