std::sinh, std::sinhf, std::sinhl

来自cppreference.com
< cpp‎ | numeric‎ | math
 
 
 
 
在标头 <cmath> 定义
(1)
float       sinh (float num );

double      sinh (double num );

longdouble sinh (longdouble num );
(C++23 前)
/* 浮点数类型 */
            sinh (/* 浮点数类型 */ num );
(C++23 起)
(C++26 起 constexpr)
float       sinhf(float num );
(2) (C++11 起)
(C++26 起为 constexpr)
longdouble sinhl(longdouble num );
(3) (C++11 起)
(C++26 起为 constexpr)
SIMD 重载(C++26 起)
在标头 <simd> 定义
template</*math-floating-point*/ V >

constexpr/*deduced-simd-t*/<V>

            sinh (const V& v_num );
(S) (C++26 起)
额外重载(C++11 起)
在标头 <cmath> 定义
template<class Integer >
double      sinh ( Integer num );
(A) (C++26 起为 constexpr)
1-3) 计算 num 的双曲正弦。标准库提供所有以无 cv 限定的浮点数类型作为形参的类型的 std::sinh 重载。(C++23 起)
S) SIMD 重载对 v_num 实施逐元素 std::sinh
(参见 math-floating-pointdeduced-simd-t 的定义。)
(C++26 起)
A) 为所有整数类型提供额外重载,将它们当做 double
(C++11 起)

目录

[编辑]参数

num - 浮点数或整数

[编辑]返回值

如果没有发生错误,那么返回 num 的双曲正弦(sinh(num)
enum
-e-num
2
)。

如果发生上溢导致的值域错误,那么返回 ±HUGE_VAL±HUGE_VALF±HUGE_VALL

如果发生下溢导致的值域错误,那么返回(舍入后的)正确结果。

[编辑]错误处理

报告 math_errhandling 中指定的错误。

如果实现支持 IEEE 浮点数算术(IEC 60559),那么

  • 如果实参是 ±0 或 ±∞,那么返回不修改的该值
  • 如果实参是 NaN,那么返回 NaN

[编辑]注解

POSIX 指定在下溢情况下,返回不修改的 num,而在不支持的情况下返回不大于 DBL_MINFLT_MINLDBL_MIN 的由实现定义的值。

额外重载不需要以 (A) 的形式提供。它们只需要能够对它们的整数类型实参 num 确保 std::sinh(num)std::sinh(static_cast<double>(num)) 的效果相同。

[编辑]示例

#include <cerrno>#include <cfenv>#include <cmath>#include <cstring>#include <iostream>// #pragma STDC FENV_ACCESS ON   int main(){constdouble x =42;   std::cout<<"sinh(1) = "<< std::sinh(1)<<'\n'<<"sinh(-1) = "<< std::sinh(-1)<<'\n'<<"log(sinh("<< x <<")+cosh("<< x <<")) = "<<std::log(std::sinh(x)+std::cosh(x))<<'\n';   // 特殊值std::cout<<"sinh(+0) = "<< std::sinh(0.0)<<'\n'<<"sinh(-0) = "<< std::sinh(-0.0)<<'\n';   // 错误处理errno=0;std::feclearexcept(FE_ALL_EXCEPT);   std::cout<<"sinh(710.5) = "<< std::sinh(710.5)<<'\n';   if(errno==ERANGE)std::cout<<" errno == ERANGE: "<<std::strerror(errno)<<'\n';if(std::fetestexcept(FE_OVERFLOW))std::cout<<" 发生 FE_OVERFLOW\n";}

输出:

sinh(1) = 1.1752 sinh(-1) = -1.1752 log(sinh(1)+cosh(1)) = 1 sinh(+0) = 0 sinh(-0) = -0 sinh(710.5) = inf errno == ERANGE: Numerical result out of range 发生 FE_OVERFLOW

[编辑]参阅

(C++11)(C++11)
计算双曲余弦(cosh(x)
(函数)[编辑]
(C++11)(C++11)
计算双曲正切(tanh(x)
(函数)[编辑]
(C++11)(C++11)(C++11)
计算反双曲正弦(arsinh(x)
(函数)[编辑]
计算复数的双曲正弦(sinh(z)
(函数模板)[编辑]
应用函数 std::sinhvalarray 的每个元素
(函数模板)[编辑]
sinh 的 C 文档
close