小编rh9*_*939的帖子

为什么math.h库中的tanh函数会给出错误的结果?

#include<stdio.h>
#include<math.h>
#define PI 2*acos(0.0)
int main(void)
{
    double theta;
    theta=tanh(1/(sqrt(3.0)));
    printf("With tanh function = %lf\n",theta);
    printf("Actual value = %lf\n",PI/6.0);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出:

tanh函数= 0.520737

实际值= 0.523599

为什么这两个值不同?它应该和我的理解一样.

c math.h

2
推荐指数
1
解决办法
152
查看次数

标签 统计

c ×1

math.h ×1