atan, atanf, atanl
From cppreference.net
Common mathematical functions
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
定义于头文件
<math.h>
|
||
|
float
atanf
(
float
arg
)
;
|
(1) | (C99 起) |
|
double
atan
(
double
arg
)
;
|
(2) | |
|
long
double
atanl
(
long
double
arg
)
;
|
(3) | (C99 起) |
|
_Decimal32 atand32
(
_Decimal32 arg
)
;
|
(4) | (C23 起) |
|
_Decimal64 atand64
(
_Decimal64 arg
)
;
|
(5) | (C23 起) |
|
_Decimal128 atand128
(
_Decimal128 arg
)
;
|
(6) | (C23 起) |
|
定义于头文件
<tgmath.h>
|
||
|
#define atan( arg )
|
(7) | (C99 起) |
1-6)
计算
arg
的反正切主值。
7)
类型泛型宏:若参数类型为
long
double
,则调用
(3)
(
atanl
);否则,若参数为整数类型或
double
类型,则调用
(2)
(
atan
);否则调用
(1)
(
atanf
)。若参数为复数,则宏调用对应的复数函数(
catanf
、
catan
、
catanl
)。
|
当且仅当实现预定义了
|
(since C23) |
目录 |
参数
| arg | - | 浮点数值 |
返回值
If no errors occur, the arc tangent of arg ( arctan(arg) ) in the range [-| π |
| 2 |
| π |
| 2 |
如果由于下溢发生范围错误,将返回正确结果(舍入后)。
错误处理
错误报告方式遵循
math_errhandling
中的规范。
如果实现支持 IEEE 浮点算术 (IEC 60559):
- 若参数为 ±0,则不作修改直接返回;
- 若参数为 +∞,则返回 +π/2;
- 若参数为 -∞,则返回 -π/2;
- 若参数为 NaN,则返回 NaN。
注释
POSIX 规范 规定,在下溢情况下,将原样返回 arg ,若不支持此行为,则返回不大于 DBL_MIN 、 FLT_MIN 和 LDBL_MIN 的实现定义值。
示例
运行此代码
输出:
atan(1) = 0.785398, 4*atan(1)=3.141593 atan(Inf) = 1.570796, 2*atan(Inf) = 3.141593 atan(-0.0) = -0.000000, atan(+0.0) = +0.000000
参考文献
- C23 标准 (ISO/IEC 9899:2024):
-
- 7.12.4.3 atan 函数 (p: TBD)
-
- 7.25 类型通用数学 <tgmath.h> (p: TBD)
-
- F.10.1.3 atan 函数 (p: TBD)
- C17 标准 (ISO/IEC 9899:2018):
-
- 7.12.4.3 atan 函数 (p: 174)
-
- 7.25 泛型数学 <tgmath.h> (p: 272-273)
-
- F.10.1.3 atan 函数 (p: 378)
- C11 标准 (ISO/IEC 9899:2011):
-
- 7.12.4.3 atan 函数 (p: 238-239)
-
- 7.25 类型泛型数学 <tgmath.h> (p: 373-375)
-
- F.10.1.3 atan 函数 (p: 519)
- C99标准(ISO/IEC 9899:1999):
-
- 7.12.4.3 atan函数 (p: 219)
-
- 7.22 泛型数学 <tgmath.h> (p: 335-337)
-
- F.9.1.3 atan函数 (p: 456)
- C89/C90 标准 (ISO/IEC 9899:1990):
-
- 4.5.2.3 atan 函数
参阅
|
(C99)
(C99)
|
使用符号确定象限计算反正切
(函数) |
|
(C99)
(C99)
|
计算反正弦 (
\({\small\arcsin{x} }\)
arcsin(x)
)
(函数) |
|
(C99)
(C99)
|
计算反余弦 (
\({\small\arccos{x} }\)
arccos(x)
)
(函数) |
|
(C99)
(C99)
|
计算正切 (
\({\small\tan{x} }\)
tan(x)
)
(函数) |
|
(C99)
(C99)
(C99)
|
计算复数反正切
(函数) |
|
C++ 文档
for
atan
|
|