std:: sinh, std:: sinhf, std:: sinhl
|
定义于头文件
<cmath>
|
||
| (1) | ||
|
float
sinh
(
float
num
)
;
double
sinh
(
double
num
)
;
|
(C++23 前) | |
|
/*floating-point-type*/
sinh ( /*floating-point-type*/ num ) ; |
(C++23 起)
(C++26 起为 constexpr) |
|
|
float
sinhf
(
float
num
)
;
|
(2) |
(C++11 起)
(C++26 起为 constexpr) |
|
long
double
sinhl
(
long
double
num
)
;
|
(3) |
(C++11 起)
(C++26 起为 constexpr) |
|
SIMD 重载
(C++26 起)
|
||
|
定义于头文件
<simd>
|
||
|
template
<
/*math-floating-point*/
V
>
constexpr
/*deduced-simd-t*/
<
V
>
|
(S) | (C++26 起) |
|
附加重载
(C++11 起)
|
||
|
定义于头文件
<cmath>
|
||
|
template
<
class
Integer
>
double sinh ( Integer num ) ; |
(A) | (C++26 起为 constexpr) |
std::sinh
的重载版本作为参数类型。
(C++23 起)
|
S)
SIMD重载对
v_num
执行逐元素的
std::sinh
运算。
|
(since C++26) |
|
A)
为所有整数类型提供了额外的重载,这些类型被视为
double
。
|
(since C++11) |
目录 |
参数
| num | - | 浮点数或整数值 |
返回值
If no errors occur, the hyperbolic sine of num ( sinh(num) , or|
e
num
-e -num |
| 2 |
如果发生因溢出导致的范围错误,将返回
±HUGE_VAL
、
±HUGE_VALF
或
±HUGE_VALL
。
如果由于下溢发生范围错误,将返回正确结果(舍入后)。
错误处理
错误报告方式遵循 math_errhandling 中的规范。
如果实现支持 IEEE 浮点算术 (IEC 60559),
- 如果参数为 ±0 或 ±∞,则原样返回。
- 如果参数为 NaN,则返回 NaN。
注释
POSIX 标准规定 ,在下溢情况下,将返回未修改的 num ;若不支持此行为,则返回一个实现定义的值,该值不大于 DBL_MIN 、 FLT_MIN 和 LDBL_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() { const double 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 raised\n"; }
输出:
sinh(1) = 1.1752
sinh(-1) = -1.1752
log(sinh(42)+cosh(42)) = 42
sinh(+0) = 0
sinh(-0) = -0
sinh(710.5) = inf
errno == ERANGE: 数值结果超出范围
FE_OVERFLOW raised
另请参阅
|
(C++11)
(C++11)
|
计算双曲余弦(
cosh(x)
)
(函数) |
|
(C++11)
(C++11)
|
计算双曲正切(
tanh(x)
)
(函数) |
|
(C++11)
(C++11)
(C++11)
|
计算反双曲正弦(
arsinh(x)
)
(函数) |
|
计算复数的双曲正弦(
sinh(z)
)
(函数模板) |
|
|
对 valarray 的每个元素应用函数
std::sinh
(函数模板) |
|
|
C 文档
关于
sinh
|
|