Numeric Constants

Overview

Contains all constants provided by C++20’s <numbers> specialized for the decimal types. These do not require C++20.

Symbol

Value

e_v

Euler’s Number

log2e_v

log2(e)

log10e_v

log10(e)

pi_v

pi

inv_pi_v

1/pi

inv_sqrtpi_v

1 / sqrt(pi)

ln2_v

ln(2) where ln is the natural log

ln10_v

ln(10)

sqrt2_v

sqrt(2)

sqrt3_v

sqrt(3)

sqrt10_v

sqrt(10)

inv_sqrt3_v

1 / sqrt(3)

cbrt2_v

cbrt(2)

cbrt10_v

cbrt(10)

egamma_v

Euler–Mascheroni constant

phi_v

The Golden Ratio

There are also non-template variables that provide the constant as a decimal64_t type.

Reference

#include <boost/decimal/numbers.hpp>

namespace boost {
namespace decimal {

template <typename Decimal>
static constexpr Decimal e_v;

template <typename Decimal>
static constexpr Decimal log2e_v;

template <typename Decimal>
static constexpr Decimal log10e_v;

template <typename Decimal>
static constexpr Decimal pi_v;

template <typename Decimal>
static constexpr Decimal inv_pi_v;

template <typename Decimal>
static constexpr Decimal inv_sqrtpi_v;

template <typename Decimal>
static constexpr Decimal ln2_v;

template <typename Decimal>
static constexpr Decimal ln10_v;

template <typename Decimal>
static constexpr Decimal sqrt2_v;

template <typename Decimal>
static constexpr Decimal sqrt3_v;

template <typename Decimal>
static constexpr Decimal sqrt10_v;

template <typename Decimal>
static constexpr Decimal inv_sqrt2_v;

template <typename Decimal>
static constexpr Decimal inv_sqrt3_v;

template <typename Decimal>
static constexpr Decimal cbrt2_v;

template <typename Decimal>
static constexpr Decimal cbrt10_v;

template <typename Decimal>
static constexpr Decimal egamma_v;

template <typename Decimal>
static constexpr Decimal phi_v;

static constexpr decimal64_t e {e_v<decimal64_t>};
static constexpr decimal64_t log2e {log2e_v<decimal64_t>};
static constexpr decimal64_t log10e {log10e_v<decimal64_t>};
static constexpr decimal64_t pi {pi_v<decimal64_t>};
static constexpr decimal64_t inv_pi {inv_pi_v<decimal64_t>};
static constexpr decimal64_t inv_sqrtpi {inv_sqrtpi_v<decimal64_t>};
static constexpr decimal64_t ln2 {ln2_v<decimal64_t>};
static constexpr decimal64_t ln10 {ln10_v<decimal64_t>};
static constexpr decimal64_t sqrt2 {sqrt2_v<decimal64_t>};
static constexpr decimal64_t sqrt3 {sqrt3_v<decimal64_t>};
static constexpr decimal64_t sqrt10 {sqrt10_v<decimal64_t>};
static constexpr decimal64_t inv_sqrt2 {inv_sqrt2_v<decimal64_t>};
static constexpr decimal64_t inv_sqrt3 {inv_sqrt3_v<decimal64_t>};
static constexpr decimal64_t cbrt2 {cbrt2_v<decimal64_t>};
static constexpr decimal64_t cbrt10 {cbrt10_v<decimal64_t>};
static constexpr decimal64_t egamma {egamma_v<decimal64_t>};
static constexpr decimal64_t phi {phi_v<decimal64_t>};

} //namespace decimal
} //namespace boost