asin, asinf, asinl
来自cppreference.com
常用数学函数
函数 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
类型 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
宏常量 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
在标头
<math.h> 定义
|
||
float
asinf( float arg );
|
(1) | (C99 起) |
double
asin( double arg );
|
(2) | |
long double asinl( long double arg );
|
(3) | (C99 起) |
在标头
<tgmath.h> 定义
|
||
#define asin( arg
)
|
(4) | (C99 起) |
1-3) 计算
arg
的弧(反)正弦主值。4) 泛型宏:若参数拥有 long double 类型,则调用
asinl
。否则,若参数拥有整数类型或
double 类型,则调用 asin
。否则调用
asinf
。若参数为复数,则宏调用对应的复数函数( casinf 、
casin 、 casinl )。参数
arg | - | 浮点值 |
返回值
若不出现错误,则返回arg
在范围 [-
π |
2 |
π |
2 |
若出现定义域错误,则返回实现定义值(受支持平台上为 NaN )。
若出现下溢所致的值域错误,则返回(舍入后的)正确结果。
错误处理
报告 math_errhandling 中指定的错误。
若 arg
在范围 [-1.0; 1.0]
外则出现定义域错误。
若实现支持 IEEE 浮点算术( IEC 60559 ),则
- 若参数为 ±0 ,则返回不修改的参数。
- 若 |arg| > 1 ,则出现定义域错误并返回 NaN 。
- 若参数为 NaN ,则返回 NaN 。
示例
运行此代码
#include <math.h> #include <stdio.h> #include <errno.h> #include <fenv.h> #include <string.h> #pragma STDC FENV_ACCESS ON 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
引用
- 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)
|
计算反余弦( \({\small\arccos{x}
}\)arccos(x) ) (函数) |
(C99)(C99)
|
计算反正切( \({\small\arctan{x}
}\)arctan(x) ) (函数) |
(C99)(C99)
|
计算反正切,以符号确定象限 (函数) |
(C99)(C99)
|
计算正弦( \({\small\sin{x} }\)sin(x) )
(函数) |
(C99)(C99)(C99)
|
计算复数反正弦 (函数) |