淡泊明志 宁静致远
分类: C/C++
2006-12-06 10:01:26
【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_asin(double x)
{
return atan2
(x, sqrt (1.0 - x * x));
}//求x的反正弦值。
int main()
{
double a =
0.5;
printf("asin(%f) = %f\n",a,asin(a));
printf("my_asin(%f) =
%f\n",a,my_asin(a));
a = -0.5;
printf("asin(%f) = %f\n",a,asin(a));
printf("my_asin(%f) =
%f\n",a,my_asin(a));
system("pause");
return 0;
}