atanh()
函数接受一个参数(-1 ≤ x ≤ 1),并返回弧双曲正切值(以弧度为单位)。
atanh()
函数包含在 <math.h>
头文件中。
atanh() 声明
double atanh(double x);
要查找 int
、float
或 long double
类型的弧双曲正切值,您可以使用类型转换运算符将其显式转换为 double
。
int x = 0; double result; result = atanh(double(x));
此外,C99 中还引入了两个函数 atanhf() 和 atanhl(),分别专门用于处理 float
和 long double
类型。
float atanhf(float x); long double atanhl(long double x);
atanh() 参数
atanh()
函数接受一个参数,该参数大于或等于 -1 且小于或等于 1。
参数 | 描述 |
---|---|
double 值 | 必需。一个大于或等于 1 ( -1 ≤ x ≤ 1 ) 的 double 值。 |
示例 1:不同参数的 atanh() 函数
#include <stdio.h>
#include <math.h>
int main()
{
// constant PI is defined
const double PI = 3.1415926;
double x, result;
x = -0.5;
result = atanh(x);
printf("atanh(%.2f) = %.2lf in radians\n", x, result);
// converting radians to degree
result = atanh(x)*180/PI;
printf("atanh(%.2f) = %.2lf in degrees\n", x, result);
// parameter not in range
x = 3;
result = atanh(x);
printf("atanh(%.2f) = %.2lf", x, result);
return 0;
}
输出
atanh(-0.50) = -0.55 in radians atanh(-0.50) = -31.47 in degrees atanh(3.00) = nan