asin, asinf, asinl

< c‎ | numeric‎ | math
在标头 <math.h> 定义
float       asinf( float arg );
(1) (C99 起)
double      asin( double arg );
(2)
long double asinl( long double arg );
(3) (C99 起)
_Decimal32  asind32( _Decimal32 arg );
(4) (C23 起)
_Decimal64  asind64( _Decimal64 arg );
(5) (C23 起)
_Decimal128 asind128( _Decimal128 arg );
(6) (C23 起)
在标头 <tgmath.h> 定义
#define asin( arg )
(7) (C99 起)
1-6) 计算 arg 的弧(反)正弦主值。
7) 泛型宏:若实参拥有 long double 类型,则调用 (3) asinl。否则,若实参拥有整数类型或 double 类型,则调用 (2) asin。否则调用 (1) asinf。若实参为复数,则宏调用对应的复数函数(casinfcasincasinl)。

仅当实现预定义了 __STDC_IEC_60559_DFP__(即实现支持十进制浮点数)时,声明函数 (4-6)

(C23 起)

参数

arg - 浮点值

返回值

若不出现错误,则返回 arg 在范围 [-
π
2
 ; +
π
2
] 中的弧(反)正弦(arcsin(arg))。

若出现定义域错误,则返回实现定义值(受支持平台上为 NaN)。

若出现下溢所致的值域错误,则返回(舍入后的)正确结果。

错误处理

报告 math_errhandling 中指定的错误。

arg 在范围 [-1.0; 1.0] 外则出现定义域错误。

若实现支持 IEEE 浮点算术(IEC 60559),则

  • 若实参为 ±0,则返回未修改的实参。
  • |arg| > 1,则出现定义域错误并返回 NaN。
  • 若实参为 NaN,则返回 NaN。

示例

#include <errno.h>
#include <fenv.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
 
#ifndef __GNUC__
#pragma STDC FENV_ACCESS ON
#endif
 
int main(void)
{
    printf("asin( 1.0) = %+f, 2*asin( 1.0)=%+f\n", asin(1), 2 * asin(1));
    printf("asin(-0.5) = %+f, 6*asin(-0.5)=%+f\n", asin(-0.5), 6 * asin(-0.5));
 
    // 特殊值
    printf("asin(0.0) = %1f, asin(-0.0)=%f\n", asin(+0.0), asin(-0.0));
 
    // 错误处理
    errno = 0; feclearexcept(FE_ALL_EXCEPT);
    printf("asin(1.1) = %f\n", asin(1.1));
    if (errno == EDOM)
        perror("    errno == EDOM");
    if (fetestexcept(FE_INVALID))
        puts("    FE_INVALID raised");
}

可能的输出:

asin( 1.0) = +1.570796, 2*asin( 1.0)=+3.141593
asin(-0.5) = -0.523599, 6*asin(-0.5)=-3.141593
asin(0.0) = 0.000000, asin(-0.0)=-0.000000
asin(1.1) = nan
    errno == EDOM: Numerical argument out of domain
    FE_INVALID raised

引用

  • C23 标准(ISO/IEC 9899:2024):
  • 7.12.4.2 The asin functions (第 TBD 页)
  • 7.25 Type-generic math <tgmath.h> (第 TBD 页)
  • F.10.1.2 The asin functions (第 TBD 页)
  • C17 标准(ISO/IEC 9899:2018):
  • 7.12.4.2 The asin functions (第 174 页)
  • 7.25 Type-generic math <tgmath.h> (第 272-273 页)
  • F.10.1.2 The asin functions (第 378 页)
  • C11 标准(ISO/IEC 9899:2011):
  • 7.12.4.2 The asin functions (第 238 页)
  • 7.25 Type-generic math <tgmath.h> (第 373-375 页)
  • F.10.1.2 The asin functions (第 518 页)
  • C99 标准(ISO/IEC 9899:1999):
  • 7.12.4.2 The asin functions (第 219 页)
  • 7.22 Type-generic math <tgmath.h> (第 335-337 页)
  • F.9.1.2 The asin functions (第 456 页)
  • C89/C90 标准(ISO/IEC 9899:1990):
  • 4.5.2.2 The asin function

参阅

(C99)(C99)
计算反余弦(arccos(x)
(函数)
(C99)(C99)
计算反正切(arctan(x)
(函数)
(C99)(C99)
计算反正切,以符号确定象限
(函数)
(C99)(C99)
计算正弦(sin(x)
(函数)
(C99)(C99)(C99)
计算复数反正弦
(函数)