std::sinh, std::sinhf, std::sinhl
來自 cppreference.com
定義於標頭檔案 <cmath> |
||
(1) | ||
float sinh ( float num ); double sinh ( double num ); |
(直至 C++23) | |
/*浮點型別*/ sinh ( /*浮點型別*/ 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< /*數學浮點型別*/ V > constexpr /*推導 SIMD 型別*/<V> |
(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 。
|
(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 文件 for sinh
|