淡泊明志 宁静致远
分类: C/C++
2006-12-05 19:03:48
【C语言库函数源代码】
【本程序在Dev C++ 4.9.9.2 下编译通过】
double my_exp(double x)
{
register double ret, value;
__asm__(
"fldl2e;"
"fmul %%st(1);"
"fst
%%st(1);\n\t"
"frndint;"
"fxch;\n\t"
"fsub %%st(1);"
"f2xm1"
: "=t" (ret), "=u"
(value)
: "0" (x)
);
ret += 1.0;
__asm__(
"fscale"
: "=t" (ret)
: "0" (ret), "u"
(value)
);
return ret;
}//求e的x次幂
int main()
{
double a = 1;
printf("exp(%f) = %f\n",a,exp(a));
printf("exp(%f) =
%f\n",a,my_exp(a));
a = 9.9;
printf("exp(%f) = %f\n",a,exp(a));
printf("exp(%f) =
%f\n",a,my_exp(a));
system("pause");
return 0;
}