std::sinh, std::sinhf, std::sinhl
来自 cppreference.cn
定义于头文件 <cmath> |
||
(1) | ||
float sinh ( float num ); double sinh ( double num ); |
(直到 C++23) | |
/*floating-point-type*/ sinh ( /*floating-point-type*/ num ); |
(自 C++23 起) (constexpr 自 C++26 起) |
|
float sinhf( float num ); |
(2) | (自 C++11 起) (constexpr 自 C++26 起) |
long double sinhl( long double num ); |
(3) | (自 C++11 起) (constexpr 自 C++26 起) |
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) | (constexpr 自 C++26 起) |
1-3) 计算 num 的双曲正弦。 库为所有 cv 无限定浮点类型提供了
std::sinh
的重载作为参数类型。(自 C++23 起)
S) SIMD 重载对 v_num 执行元素wise
std::sinh 操作。
|
(自 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_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'; // special values std::cout << "sinh(+0) = " << std::sinh(0.0) << '\n' << "sinh(-0) = " << std::sinh(-0.0) << '\n'; // error handling 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: Numerical result out of range 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)) (函数模板) | |
将函数 std::sinh 应用于 valarray 的每个元素 (函数模板) | |
C 文档 关于 sinh
|