pow()函数的运行机制

我用C++做个开x的n次方根的程序,可是一直不明白pow()函数是什么代码求 pow(x, 1 / n)。
希望回答pow()函数的代码,不是返回另一个函数的那种(递归是可以的),希望能刨根问底到最基础的那层函数。
我最多搜到这里:

  using ::pow;

#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  inline _GLIBCXX_CONSTEXPR float
  pow(float __x, float __y)
  { return __builtin_powf(__x, __y); }

  inline _GLIBCXX_CONSTEXPR long double
  pow(long double __x, long double __y)
  { return __builtin_powl(__x, __y); }

#if __cplusplus < 201103L
  // _GLIBCXX_RESOLVE_LIB_DEFECTS
  // DR 550. What should the return type of pow(float,int) be?
  inline double
  pow(double __x, int __i)
  { return __builtin_powi(__x, __i); }

  inline float
  pow(float __x, int __n)
  { return __builtin_powif(__x, __n); }

  inline long double
  pow(long double __x, int __n)
  { return __builtin_powil(__x, __n); }
#endif
#endif

  template<typename _Tp, typename _Up>
    inline _GLIBCXX_CONSTEXPR
    typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
    pow(_Tp __x, _Up __y)
    {
      typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
      return pow(__type(__x), __type(__y));
    }

感谢每一个回答!

n是整数吗,整数可以这样写,不是整数就很复杂了,不会。

/*----------------------------------*/
/* Author : KaMtuo                  */
/* Email : kamtuo@qq.com            */
/* Creation_time : 2022-08-09 15:12 */
/* Software : Visual Studio Code    */
/*----------------------------------*/

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <queue>
#include <vector>
#include <map>
#include <cmath>

#define endl "\n"

using std::cin;
using std::cout;
using std::max;
using std::min;
using std::sort;
using std::queue;
using std::priority_queue;
using std::vector;
using std::map;
using std::string;


double doublepow(double a, int b) {
    double l = 0, r = a;
    while (r - l >= 1e-6) {
        double mid = (l + r) / 2.0;
        double k = 1.0;
        for (int i = 1; i <= b; i ++) k *= mid;
        if (k >= a) r = mid;
        else l = mid; 
    }
    return l;
}


int main() {
    double a, n;
    cin >> a >> n;
    printf("%.6lf\n", doublepow(a, n));
    return 0;
}

这个可以满足不是整数的情况,不过用了其他函数,不符合要求了。

double doublepow(double a, double b) {
    return exp(log(a) * b);
}

这个函数可优化的东西很多, 编译器最终用的都是优化后非常复杂的, 开源的编译器如gcc可以从中找到代码
网上也可以搜索到, 找到一个: https://azrael.digipen.edu/~mmead/www/Courses/CS120/pow-stuff.html

谢谢,您提供的链接很有用!
我追下去发现是一大堆函数,很有学习价值。
优化后的代码比实际调用复杂多了……
感想:写这种东西的人数学太好了!(* /ω\*)