Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) GetMaxLong

 

GetMaxLong is a checking code snippet to get the maximal value of a long.

 

GetMaxLong has two flavors:

  1. STL GetMaxLong
  2. Boost GetMaxLong

 

 

 

 

 

STL GetMaxLong

 

#include <limits>

///GetMaxLong returns the highest possible value of a long.
///From http://www.richelbilderbeek.nl/CppGetMaxLong.htm
long GetMaxLong()
{
  return std::numeric_limits<long>::max();
}

 

 

 

 

 

Boost GetMaxLong

 


#include <boost/numeric/conversion/bounds.hpp>

///GetMaxLong returns the highest possible value of a long.
///From http://www.richelbilderbeek.nl/CppGetMaxLong.htm
long GetMaxLong()
{
  return boost::numeric::bounds<long>::highest();
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict