C++官网参考链接:https://cplusplus.com/reference/cmath/asin/
函数
<cmath> <ctgmath>
asin
C90
double asin (double x);
C99
double asin (double x);
float asinf (float x);
long double asinl (long double x);
C++98
double asin (double x);
float asin (float x);
long double asin (long double x);
C++11
double asin (double x);
float asin (float x);
long double asin (long double x);
double asin (T x); // additional overloads for integral types
计算反正弦
返回以弧度表示x的反正弦的值。
在三角学中,反正弦是正弦(sine)的逆运算。
C99
头文件<tgmath.h>提供了该函数的泛型类型的宏版本。
C++98
此函数在<valarray>中重载(参见valarray asin)。
C++11
在此头文件(<cmath>)中为整型(integral types)提供了额外的重载:这些重载在计算之前有效地将x转换为double类型(定义T为任何整型(integral type))。
此函数在<complex>和<valarray>中也被重载(参见complex asin和valarray asin)。
形参
x
在区间[-1,+1]内计算其反正弦的值。
如果实参超出了这个区间,就会发生定义域错误。
返回值
x的反正弦返回的值,在[-pi/2,pi/2]弧度范围内。
1弧度等于180/PI度。
C90(C++98)
如果发生定义域错误,将全局变量errno设置为EDOM。
C99(C++11)
如果发生定义域错误:
—math_errhandling具有MATH_ERRNO集合:全局变量errno设置为EDOM。
—math_errhandling具有MATH_ERREXCEPT集合:将引发FE_INVALID。
用例
/* asin example */
#include <stdio.h> /* printf */
#include <math.h> /* asin */
#define PI 3.14159265
int main ()
{
double param, result;
param = 0.5;
result = asin (param) * 180.0 / PI;
printf ("The arc sine of %f is %f degrees\n", param, result);
return 0;
}
输出: