6.11.180 tanhf Function

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

Include

<math.h>

Prototype

float tanhf(float x);

Argument

x
value for which to return the hyperbolic tangent

Return Value

Returns the hyperbolic tangent of x in the ranges of -1 to 1 inclusive.

Remarks

No domain or range error will occur.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

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

int main(void)
{
  float x, y;

  x = -1.0F;
  y = tanhf(x);
  printf("The hyperbolic tangent of %f is %f\n", x, y);

  x = 0.0F;
  y = tanhf(x);
  printf("The hyperbolic tangent of %f is %f\n", x, y);
}

Example Output

The hyperbolic tangent of -1.000000 is -0.761594
The hyperbolic tangent of 0.000000 is 0.000000