Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Floating-Point Constant Macros

All macros of the type BOOST_FLOAT16_C, BOOST_FLOAT32_C, BOOST_FLOAT64_C, BOOST_FLOAT80_C, BOOST_FLOAT128_C, and BOOST_FLOATMAX_C are always defined after inclusion of <boost/cstdfloat.hpp>.

These allow floating-point constants of at least the specified width to be declared:

// Declare Archimedes' constant using float32_t with approximately 7 decimal digits of precision.
static const boost::float32_t pi = BOOST_FLOAT32_C(3.1415926536);

// Declare the Euler-gamma constant with approximately 15 decimal digits of precision.
static const boost::float64_t euler =

// Declare the Golden Ratio constant with the maximum decimal digits of precision that the platform supports.
static const boost::floatmax_t golden_ratio =
[Tip] Tip

Boost.Math provides many constants 'built-in', so always use Boost.Math constants if available, for example:

// Display the constant pi to the maximum available precision.
  boost::floatmax_t pi_max = boost::math::constants::pi<boost::floatmax_t>();
  std::cout << "Most precise pi = "  << pi_max << std::endl;
// If floatmax_t is float_128_t, then
// Most precise pi = 3.141592653589793238462643383279503

from cstdfloat_example.cpp.

See the complete list of constants.