淡泊明志 宁静致远
分类: C/C++
2006-12-06 10:03:37
【C语言库函数源代码】
【本程序在Dev C++ 4.9.9.2 下编译通过】
double atan2 (double x, double y)
{
register double ret;
__asm__(
"fpatan\n\t"
"fld %%st(0)"
: "=t" (ret)
: "0" (y), "u" (x)
);
return ret;
}//求x / y的反正切值。
double my_acos(double x)
{
return atan2
(sqrt (1.0 - x * x), x);
}//求x的反余弦值。
int main()
{
double a =
0.5;
printf("acos(%f) = %f\n",a,acos(a));
printf("my_acos(%f) =
%f\n",a,my_acos(a));
a = -0.5;
printf("acos(%f) = %f\n",a,acos(a));
printf("my_acos(%f) =
%f\n",a,my_acos(a));
system("pause");
return 0;
}