Compute the hyperbolic sine
#include <math.h> double sinh( double x ); float sinhf( float x ); long double asinhl( long double x );
These functions compute the hyperbolic sine of x radians. A range error occurs if the magnitude of x is too large.
To check for error situations, use feclearexcept() and fetestexcept():
The hyperbolic sine value.
If the result would cause an overflow, a range error occurs, and the functions return ±HUGE_VAL, ±HUGE_VALF, and ±HUGE_VALL (with the same sign as x), as appropriate for the type of the function.
If x is NaN, NaN is returned. If x is ±0 or ±Inf, x is returned. If x is subnormal, a range error may occur and x is returned.
#include <stdio.h> #include <math.h> #include <fenv.h> #include <stdlib.h> int main( void ) { int except_flags; feclearexcept(FE_ALL_EXCEPT); printf( "%f\n", sinh(.5) ); except_flags = fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW); if(except_flags) { /* An error occurred; handle it appropriately. */ } return EXIT_SUCCESS; }
produces the output:
0.521095
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |