std:: cosh, std:: coshf, std:: coshl
|
Definiert in Header
<cmath>
|
||
| (1) | ||
|
float
cosh
(
float
num
)
;
double
cosh
(
double
num
)
;
|
(bis C++23) | |
|
/*floating-point-type*/
cosh ( /*floating-point-type*/ num ) ; |
(seit C++23)
(constexpr seit C++26) |
|
|
float
coshf
(
float
num
)
;
|
(2) |
(seit C++11)
(constexpr seit C++26) |
|
long
double
coshl
(
long
double
num
)
;
|
(3) |
(seit C++11)
(constexpr seit C++26) |
|
SIMD-Überladung
(seit C++26)
|
||
|
Definiert in Header
<simd>
|
||
|
template
<
/*math-floating-point*/
V
>
constexpr
/*deduced-simd-t*/
<
V
>
|
(S) | (seit C++26) |
|
Zusätzliche Überladungen
(seit C++11)
|
||
|
Definiert in Header
<cmath>
|
||
|
template
<
class
Integer
>
double cosh ( Integer num ) ; |
(A) | (constexpr seit C++26) |
std::cosh
für alle cv-unqualifizierten Gleitkommatypen als Typ des Parameters an.
(since C++23)
|
S)
Die SIMD-Überladung führt eine elementweise
std::cosh
-Operation auf
v_num
aus.
|
(seit C++26) |
|
A)
Zusätzliche Überladungen werden für alle Ganzzahltypen bereitgestellt, die als
double
behandelt werden.
|
(since C++11) |
Inhaltsverzeichnis |
Parameter
| num | - | Gleitkomma- oder Ganzzahlwert |
Rückgabewert
If no errors occur, the hyperbolic cosine of num ( cosh(num) , or|
e
num
+e -num |
| 2 |
Wenn ein Bereichsfehler aufgrund von Überlauf auftritt,
+HUGE_VAL
,
+HUGE_VALF
, oder
+HUGE_VALL
wird zurückgegeben.
Fehlerbehandlung
Fehler werden gemeldet, wie in math_errhandling spezifiziert.
Wenn die Implementierung IEEE-Gleitkommaarithmetik (IEC 60559) unterstützt,
- Wenn das Argument ±0 ist, wird 1 zurückgegeben.
- Wenn das Argument ±∞ ist, wird +∞ zurückgegeben.
- Wenn das Argument NaN ist, wird NaN zurückgegeben.
Hinweise
Für den IEEE-kompatiblen Typ double , falls |num| > 710.5 , dann std :: cosh ( num ) führt einen Überlauf aus.
Die zusätzlichen Überladungen müssen nicht exakt wie (A) bereitgestellt werden. Sie müssen lediglich sicherstellen, dass für ihr Argument num vom Ganzzahltyp std :: cosh ( num ) die gleiche Wirkung hat wie std :: cosh ( static_cast < double > ( num ) ) .
Beispiel
#include <cerrno> #include <cfenv> #include <cmath> #include <cstring> #include <iostream> // #pragma STDC FENV_ACCESS ON int main() { const double x = 42; std::cout << "cosh(1) = " << std::cosh(1) << '\n' << "cosh(-1) = " << std::cosh(-1) << '\n' << "log(sinh(" << x << ")+cosh(" << x << ")) = " << std::log(std::sinh(x) + std::cosh(x)) << '\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"; }
Mögliche Ausgabe:
cosh(1) = 1.54308
cosh(-1) = 1.54308
log(sinh(42)+cosh(42)) = 42
cosh(+0) = 1
cosh(-0) = 1
cosh(710.5) = inf
errno == ERANGE: Numerical result out of range
FE_OVERFLOW raised
Siehe auch
|
(C++11)
(C++11)
|
berechnet den hyperbolischen Sinus (
sinh(x)
)
(Funktion) |
|
(C++11)
(C++11)
|
berechnet den hyperbolischen Tangens (
tanh(x)
)
(Funktion) |
|
(C++11)
(C++11)
(C++11)
|
berechnet den Areakosinus Hyperbolicus (
arcosh(x)
)
(Funktion) |
|
berechnet den hyperbolischen Kosinus einer komplexen Zahl (
cosh(z)
)
(Funktions-Template) |
|
|
wendet die Funktion
std::cosh
auf jedes Element des valarray an
(Funktions-Template) |
|
|
C-Dokumentation
für
cosh
|
|