cosh(), coshf(), coshl()

Compute the hyperbolic cosine

Synopsis:

#include <math.h>

double cosh( double x );

float coshf( float x );

long double coshl( long double x );

Arguments:

x
The angle, in radians, for which you want to compute the hyperbolic cosine.

Library:

libm

Use the -l m option to qcc to link against this library.

Description:

These functions compute the hyperbolic cosine of x radians. A range error occurs if the magnitude of x is too large.

To check for error situations, use feclearexcept() and fetestexcept():

Returns:

The hyperbolic cosine of x. If the correct value would cause an overflow, a range error occurs, and cosh(), coshf(), and coshl() return HUGE_VAL, HUGE_VALF, and HUGE_VALL, respectively.

If x is: These functions return:
NaN NaN
±0 1.0
±Inf ±Inf

Errors:

FE_OVERFLOW
The result would cause an overflow.

Examples:

#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", cosh(.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:

1.127626

Classification:

ANSI, POSIX 1003.1

Safety:  
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes