coshl
在头文件<math.h>中定义 | ? | ? |
---|---|---|
float coshf( float arg ); | (1) | (since C99) |
double cosh( double arg ); | (2) | ? |
long double coshl( long double arg ); | (3) | (since C99) |
Defined in header <tgmath.h> | ? | ? |
#define cosh( arg ) | (4) | (since C99) |
1-3)计算双曲余弦arg
。
4)类型 - 通用宏:如果参数具有类型long double
,coshl
则被调用。否则,如果参数具有整数类型或类型double
,cosh
则调用该参数。否则,coshf
被调用。如果参数是复杂的,则宏调用相应的复变函数(ccoshf
,ccosh
,ccoshl
)。
参数
arg | - | 浮点值代表双曲线角度 |
---|
返回值
如果没有错误发生,则arg
(cosh(arg)或。的双曲余弦
| earg+e-arg |
|:----|
| 2 |
)返回。
如果范围误差由于发生溢出,+HUGE_VAL
,+HUGE_VALF
,或+HUGE_VALL
返回。
错误处理
按照math_errhandling中的指定报告错误。
如果实现支持IEEE浮点运算(IEC 60559),
- 如果参数为±0,则返回1
- 如果参数是±∞,则返回+∞
- 如果参数是NaN,则返回NaN
笔记
对于IEEE兼容类型double
,如果| arg | > 710.5,然后cosh(arg)
溢出。
例
#include <stdio.h>
#include <math.h>
#include <errno.h>
#include <fenv.h>
#pragma STDC FENV_ACCESS ON
int main(void)
{
printf("cosh(1) = %f\ncosh(-1)= %f\n", cosh(1), cosh(-1));
printf("log(sinh(1) + cosh(1))=%f\n", log(sinh(1)+cosh(1)));
// special values
printf("cosh(+0) = %f\ncosh(-0) = %f\n", cosh(0.0), cosh(-0.0));
// error handling
errno=0; feclearexcept(FE_ALL_EXCEPT);
printf("cosh(710.5) = %f\n", cosh(710.5));
if(errno == ERANGE) perror(" errno == ERANGE");
if(fetestexcept(FE_OVERFLOW)) puts(" FE_OVERFLOW raised");
}
可能的输出:
cosh(1) = 1.543081
cosh(-1)= 1.543081
log(sinh(1) + cosh(1))=1.000000
cosh(+0) = 1.000000
cosh(-0) = 1.000000
cosh(710.5) = inf
errno == ERANGE: Numerical result out of range
FE_OVERFLOW raised
参考
- C11标准(ISO / IEC 9899:2011):
- 7.12.5.4 cosh函数(p:241)
- 7.25类型通用数学<tgmath.h>(p:373-375)
- F.10.2.4 cosh函数(p:520)
- C99标准(ISO / IEC 9899:1999):
- 7.12.5.4 cosh函数(p:222)
- 7.22类型通用数学<tgmath.h>(p:335-337)
- F.9.2.4 cosh函数(p:457)
- C89 / C90标准(ISO / IEC 9899:1990):
- 4.5.3.1 cosh函数
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com