Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) GetMaxDouble

 

Check code snippet to get the maximal value of a double.

 

GetMaxDouble has two flavors:

 

 

 

 

 

STL GetMaxDouble

 

#include <limits>

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

 

 

 

 

 

Boost GetMaxDouble

 

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

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

 

 

 

 

 

GetMaxDouble test

 

#include <iostream>

int main()
{
  std::cout << "Max double: " << GetMaxDouble() << std::endl;
}

 

Screen output:

 

Max double: 1.79769e+308

 

 

 

 

 

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

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict