coshf Function

Calculates the hyperbolic cosine function of a single precision floating-point value.

Include

<math.h>

Prototype

float coshf (float x);

Argument

x
value for which to return the hyperbolic cosine

Return Value

Returns the hyperbolic cosine of x.

Remarks

A range error will occur if the magnitude of x is too large.

Example

#include <math.h>
#include <stdio.h>
#include <errno.h>

int main(void)
{
  float x, y;

  errno = 0;
  x = -1.0F;
  y = coshf (x);
  if (errno)
    perror("Error");
  printf("The hyperbolic cosine of %f is %f\n", x, y);

  errno = 0;
  x = 0.0F;
  y = coshf (x);
  if (errno)
    perror("Error");
  printf("The hyperbolic cosine of %f is %f\n", x, y);

  errno = 0;
  x = 720.0F;
  y = coshf (x);
  if (errno)
    perror("Error");
  printf("The hyperbolic cosine of %f is %f\n", x, y);
}

Example Output

The hyperbolic cosine of -1.000000 is 1.543081
The hyperbolic cosine of 0.000000 is 1.000000
Error: range error
The hyperbolic cosine of 720.000000 is inf