我一直在寻找用于计算的有效方法b(说a = 2和b = 50).为了开始,我决定看一下Math.Pow()函数的实现.但在.NET Reflector中,我发现的只有:
[MethodImpl(MethodImplOptions.InternalCall), SecuritySafeCritical]
public static extern double Pow(double x, double y);
Run Code Online (Sandbox Code Playgroud)
当我调用Math.Pow()函数时,我可以看到内部发生了什么的一些资源?
我需要一个高效的算法在两个浮点数之间做数学::幂函数,你知道怎么做,(我需要算法不使用函数本身)
我读到pow(double,double)函数在"math.h"中定义,但我找不到它的声明.
有人知道这个函数声明的位置吗?它在C中实现的位置?
参考:
http://publications.gbdirect.co.uk/c_book/chapter9/maths_functions.html
我理解如何pow()正确使用我只是想知道为什么当我运行这个代码ans= inf.
我很难理解这一点.
这是否与chars有关,只能采用-128到+127的值并pow()计算方式?
这与" %c"我的第一个scanf参数中的空间有什么关系吗?
Linux 4.9.0-7-amd64 debian 4.9.110-1 gcc版本6.3.020170516
#include <stdio.h>
#include <math.h>
int main ()
{
char base, exp;
float ans;
printf("Enter base number : ");
scanf(" %c", &base);
printf("Enter exp number : ");
scanf(" %c", &exp);
ans = pow(base,exp);
printf("%c raised to the %c power equals %f", base, exp, ans);
return 0;
}
Run Code Online (Sandbox Code Playgroud)