41template <
typename F,
typename I,
42 std::enable_if_t<std::is_floating_point_v<F> && std::is_integral_v<I>,
44constexpr auto root(F x, I n) -> F {
46 return std::numeric_limits<F>::quiet_NaN();
50 return std::numeric_limits<F>::quiet_NaN();
54 if ((x > std::numeric_limits<F>::max()) ||
55 (x < std::numeric_limits<F>::min())) {
59 constexpr int max_loops = 1000;
61 for (
int i = 0; i < max_loops; ++i) {
62 F next_value = (
static_cast<F
>(n -
one<I>) * value +
65 if (value == next_value) {
83template <
typename IB,
typename IE,
84 std::enable_if_t<std::is_integral_v<IB> && std::is_integral_v<IE>,
void*> =
86constexpr auto root(IB x, IE n) ->
double {
87 return root(
static_cast<double>(x), n);
constexpr auto pow_pos_int(T base, I exp) -> T
Calculate the value of base raised to the power exp.
Namespace of constexpr variables and functions.
constexpr auto root(F x, I n) -> F
Calculate n-th root .
Definition of pow_pos_int function.