首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::cosh

Defined in header <cmath>

float cosh( float arg );

(1)

double cosh( double arg );

(2)

long double cosh( long double arg );

(3)

double cosh( Integral arg );

(4)

(since C++11)

计算双曲余弦arg...

4%29一组过载或接受任意参数的函数模板积分型等于2%29%28double29%。

参数

arg

-

value of a floating-point or Integral type

返回值

如果没有错误发生,则双曲余弦arg%28 COSH%28 ARG%29,或

耳+e-Arg

*。

%29被返回。

如果溢出导致范围错误,+HUGE_VAL,,,+HUGE_VALF,或+HUGE_VALL会被归还。

错误处理

错误按数学[医]错误处理...

如果实现支持ieee浮点算法%28IEC 60559%29,

  • 如果参数为±0,则返回1
  • 如果参数为±∞,则返回+∞
  • 如果参数为nan,则返回nan。

注记

适用于ieee兼容的类型。double,如果arg>710.5,那么cosh(arg)溢出。

二次

代码语言:javascript
复制
#include <iostream>
#include <cmath>
#include <cerrno>
#include <cstring>
#include <cfenv>
 
#pragma STDC FENV_ACCESS ON
int main()
{
    std::cout << "cosh(1) = " << std::cosh(1) << '\n'
              << "cosh(-1) = " << std::cosh(-1) << '\n'
              << "log(sinh(1)+cosh(1)=" << std::log(std::sinh(1)+std::cosh(1)) << '\n';
    // special values
    std::cout << "cosh(+0) = " << std::cosh(0.0) << '\n'
              << "cosh(-0) = " << std::cosh(-0.0) << '\n';
    // error handling 
    errno=0; std::feclearexcept(FE_ALL_EXCEPT);
    std::cout << "cosh(710.5) = " << std::cosh(710.5) << '\n';
    if(errno == ERANGE)
        std::cout << "    errno == ERANGE: " << std::strerror(errno) << '\n';
    if(std::fetestexcept(FE_OVERFLOW))
        std::cout << "    FE_OVERFLOW raised\n";
}

二次

另见

sinh

computes hyperbolic sine (sh(x)) (function)

tanh

hyperbolic tangent (function)

acosh (C++11)

computes the inverse hyperbolic cosine (arcosh(x)) (function)

cosh(std::complex)

computes hyperbolic cosine of a complex number (ch(z)) (function template)

cosh(std::valarray)

applies the function std::cosh to each element of valarray (function template)

c COSH文件

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券