To determine the ranges of numeric types with
template<class N> struct bounds { static N lowest () { return implementation_defined; } static N highest () { return implementation_defined; } static N smallest() { return implementation_defined; } }; Members
Returns the minimum finite value, equivalent to
Returns the maximum finite value, equivalent to
Returns the smallest positive normalized value for floating point types with denormalization, or returns 0 for integral types.
The following example demonstrates the use of #include <iostream> #include <boost/numeric/conversion/bounds.hpp> #include <boost/limits.hpp> int main() { std::cout << "numeric::bounds versus numeric_limits example.\n"; std::cout << "The maximum value for float:\n"; std::cout << boost::numeric::bounds<float>::highest() << "\n"; std::cout << std::numeric_limits<float>::max() << "\n"; std::cout << "The minimum value for float:\n"; std::cout << boost::numeric::bounds<float>::lowest() << "\n"; std::cout << -std::numeric_limits<float>::max() << "\n"; std::cout << "The smallest positive value for float:\n"; std::cout << boost::numeric::bounds<float>::smallest() << "\n"; std::cout << std::numeric_limits<float>::min() << "\n"; return 0; } |