cosh, coshf, coshl
来自cppreference.com
                    
                                        
                    
                    
                                                            
                    |   在标头  <math.h> 定义
  | 
||
|   float       coshf( float arg );  | 
(1) | (C99 起) | 
|   double      cosh( double arg );  | 
(2) | |
|   long double coshl( long double arg );  | 
(3) | (C99 起) | 
|   在标头  <tgmath.h> 定义
  | 
||
|   #define cosh( arg )  | 
(4) | (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))); // 特殊值 printf("cosh(+0) = %f\ncosh(-0) = %f\n", cosh(0.0), cosh(-0.0)); // 错误处理 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 The cosh functions (第 241 页)
 
- 7.25 Type-generic math <tgmath.h> (第 373-375 页)
 
- F.10.2.4 The cosh functions (第 520 页)
 
- C99 标准(ISO/IEC 9899:1999):
 
- 7.12.5.4 The cosh functions (第 222 页)
 
- 7.22 Type-generic math <tgmath.h> (第 335-337 页)
 
- F.9.2.4 The cosh functions (第 457 页)
 
- C89/C90 标准(ISO/IEC 9899:1990):
 
- 4.5.3.1 The cosh function
 
参阅
|    (C99)(C99)  | 
   计算双曲正弦( sinh(x) )   (函数)  | 
|    (C99)(C99)  | 
   计算双曲正切( tanh(x) )   (函数)  | 
|    (C99)(C99)(C99)  | 
   计算反双曲余弦( arcosh(x) )   (函数)  | 
|    (C99)(C99)(C99)  | 
  计算复双曲余弦  (函数)  |