C++ cmath atan() 函数

定义和用法

atan() 函数返回数的反正切值,以弧度表示。

atan() 函数定义在 <cmath> 头文件中。

提示:atan() 函数仅返回 -PI/2 和 PI/2 之间的角度。atan2() 函数可以返回任何角度。

实例

返回不同数的反正切值:

cout << atan(0.5);
cout << atan(-0.5);
cout << atan(5);
cout << atan(-5);
cout << atan(100);
cout << atan(-100);

亲自试一试

语法

以下之一:

atan(double number);
atan(float number);

参数

参数 描述
number

必需。指定一个数。

如果该数为整数类型,则将被视为 double 类型。

技术细节

返回:

如果参数为 float 类型,则返回 float 值。

在其他情况下,返回 double 值,表示数的反正切值。