如何使用Dev C++检查数学库函数sqrt()中的代码?

kar*_*olu 1 c c++

我想检查数学库函数 里面的代码sqrt()怎么可能?
我正在使用DEV C++.

Lig*_*ica 7

这些东西被编译到工具链运行时,但由于GCC及其Windows端口MinGW(这是你的Dev-C++ IDE调用的)是开源的,你可以看看源代码.

这是最新的MinGW GCC; 这两个版本似乎基本上将所有工作推迟到处理器(这不是一个惊喜,因为x86 - 通过指令集的x87部分 - 本身支持平方根计算).

long double

#include <math.h>
#include <errno.h>

extern long double  __QNANL;

long double
sqrtl (long double x)
{
  if (x < 0.0L )
    {
      errno = EDOM;
      return __QNANL;
    }
  else
    {
      long double res;
      asm ("fsqrt" : "=t" (res) : "0" (x));
      return res;
    }
}
Run Code Online (Sandbox Code Playgroud)

float

#include <math.h>
#include <errno.h>

extern float  __QNANF;

float
sqrtf (float x)
{
  if (x < 0.0F )
    {
      errno = EDOM;
      return __QNANF;
    }
  else
    {
      float res;
      asm ("fsqrt" : "=t" (res) : "0" (x));
      return res;
    }
}
Run Code Online (Sandbox Code Playgroud)