std::sinh,s...f,std::sinhl(3)
π std::sinh, std::sinhf, std::sinhl π
okay bestie, welcome to the C++ Standard Library page for the hyperbolic sine crew β that's std::sinh, std::sinhf, and std::sinhl, no cap. They live in <cmath> and they're literally serving math realness. π¦
β¨ NAME β¨
std::sinh, std::sinhf, std::sinhl β yeah, the name section is just the homies listing themselves again. iconic behavior honestly. π
πΈ SYNOPSIS πΈ
First things first, these bad girls are defined in header <cmath>. periodt. π
float sinh ( float num );
double sinh ( double num ); (until C++23)
long double sinh ( long double num );
/* floating-point-type */ (since C++23)
sinh ( /* floating-point-type */ num );
(constexpr since C++26)
float sinhf( float num ); (1) (2) (since C++11)
(constexpr
since C++26)
long double sinhl( long double num ); (3) (since C++11)
(constexpr
since C++26)
Additional overloads (since C++11)
Defined in header <cmath>
template< class Integer > (A)
(constexpr since C++26)
double sinh ( Integer num );
So let's break the lore down for you, because there's a lot going on and it's all slay:
- 1-3) Computes the hyperbolic sine of
num. that's the whole job bestie. π - Since C++23, the library provides overloads of
std::sinhfor all cv-unqualified floating-point types as the type of the parameter. yes, all of them. she's flexible like that. β¨ - A) Additional overloads are provided for all integer types (since C++11), and those get treated as
double. so yourintwalks in and gets thedoubleglow-up. π§
π Parameters π
numβ a floating-point or integer value. that's it, that's the whole vibe check. π
π₯ Return value π₯
If no errors occur, you get the hyperbolic sine of num (sinh(num), or:
enum
-e-num
2
) returned to you. and yes that formula is giving what it needs to give. π
If a range error due to overflow occurs, you get Β±HUGE_VAL, Β±HUGE_VALF, or Β±HUGE_VALL returned. so like, infinity said hi. π
If a range error occurs due to underflow, the correct result (after rounding) is returned. tiny but valid. we respect her. π
π Error handling π
Errors are reported as specified in math_errhandling. (go read that one too, iykyk.)
If the implementation supports IEEE floating-point arithmetic (IEC 60559), then:
- if the argument is
Β±0orΒ±β, it is returned unmodified. she returns exactly what she got. no notes. π - if the argument is
NaN,NaNis returned. fair enough honestly. π
π«Ά Notes π«Ά
POSIX specifies that in case of underflow, num is returned unmodified, and if that is not supported, an implementation-defined value no greater than DBL_MIN, FLT_MIN, and LDBL_MIN is returned. so like, don't count on the exact tiny number, bestie. π
Also β and this is the important disclaimer β the additional overloads are not required to be provided exactly as (A). They only need to be sufficient to ensure that for their argument num of integer type, std::sinh(num) has the same effect as std::sinh(static_cast<double>(num)). so the behavior is the contract, the implementation is just vibes. β¨
β Example β
run this code, it's literally so fun:
#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";
}
π Output π
This is what she prints, bestie, look at that overflow pop off:
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
π¦ See also π¦
cosh,coshf,coshl(C++11) β computes hyperbolic cosine (cosh(x)) (function)tanh,tanhf,tanhl(C++11) β computes hyperbolic tangent (tanh(x)) (function)asinh,asinhf,asinhl(C++11) β computes the inverse hyperbolic sine (arsinh(x)) (function)sinh(std::complex)β computes hyperbolic sine of a complex number (sinh(z)) (function template)sinh(std::valarray)β applies the functionstd::sinhto each element ofvalarray(function template)- C documentation for
sinh
ok that's the whole page bestie, go forth and compute your hyperbolic sines π β¨
and finally, the cute little sign-off: this was served up fresh from http://cppreference.com, dated 2024.06.10, and it's the std::sinh,s...f,std::sinhl(3) page. love her, bookmark her, hydrate. πππ«Ά
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms