函式
<cmath> <ctgmath>

asin

double asin(double x);
     double asin  (double x);      float asinf (float x);long double asinl (long double x);
     double asin (double x);      float asin (float x);long double asin (long double x);
     double asin (double x);      float asin (float x);long double asin (long double x);     double asin (T x);           // additional overloads for integral types
計算反正弦
返回 x 的反正弦主值,以弧度表示。

在三角學中,反正弦正弦的逆運算。

標頭檔案 <tgmath.h> 提供了此函式的型別通用宏版本。
此函式在 <valarray> 中被過載(參見 valarray asin)。
此標頭檔案 (<cmath>) 為整型型別提供了額外的過載:這些過載在計算前有效地將 x 轉換為 double(為任何整型型別T 定義)。

此函式也在 <complex><valarray> 中被過載(參見 complex asinvalarray asin)。

引數

x
計算其反正弦的值,在區間 [-1,+1] 內。
如果引數超出此區間,會發生定義域錯誤

返回值

x 的反正弦主值,在區間 [-pi/2,+pi/2] 弧度內。
弧度等於 180/PI

如果發生定義域錯誤,全域性變數 errno 會被設定為 EDOM
如果發生定義域錯誤
- 且 math_errhandling 設定了 MATH_ERRNO:全域性變數 errno 會被設定為 EDOM
- 且 math_errhandling 設定了 MATH_ERREXCEPT:將引發 FE_INVALID

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* 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;
}

輸出

The arc sine of 0.500000 is 30.000000 degrees.


另見