45template <
typename T,
typename = std::enable_if_t<std::is_
floating_po
int_v<T>>>
46constexpr auto exp(T x) -> T {
50 if (x < std::numeric_limits<T>::min()) {
54 constexpr auto thresh_inf =
55 static_cast<T
>(std::numeric_limits<T>::max_exponent);
56 if (x >= thresh_inf) {
57 return std::numeric_limits<T>::infinity();
60 int int_part =
static_cast<int>(
trunc(x));
61 T rem_part = x -
static_cast<T
>(int_part);
64 return exp_int_part * exp_rem_part;
Definition of exp_maclaurin function.
constexpr auto pow_pos_int(T base, I exp) -> T
Calculate the value of base raised to the power exp.
constexpr auto exp_maclaurin(T x) -> T
Calculate exponential function with Maclaurin series.
Namespace of constexpr variables and functions.
constexpr auto exp(T x) -> T
Calculate exponential function .
constexpr T napier
Value of Napier's constant (or Euler's number), .
constexpr auto trunc(T x) -> T
Truncate the decimal part of a number x.
Definition of pow_pos_int function.
Definition of trunc function.