Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

tan, tanf, tanl, tanh, tanhf, tanhl

Calculates the tangent (tan, tanf, or tanl), or hyperbolic tangent (tanh, tanhf, or tanhl).

double tan(
   double x 
float tan(
   float x 
);  // C++ only
long double tan(
   long double x
);  // C++ only
float tanf(
   float x 
long double tanl(
   long double x
double tanh(
   double x 
float tanh(
   float x 
);  // C++ only
long double tanh(
   long double x
);  // C++ only
float tanhf(
   float x 
long double tanhl(
   long double x

Angle in radians.

The tan functions return the tangent of x. If x is greater than or equal to 263, or less than or equal to –263, a loss of significance in the result occurs.

The tanh functions return the hyperbolic tangent of x. There is no error return.


SEH Exception

Matherr Exception




± ∞ (tan, tanf)



Because C++ allows overloading, you can call overloads of tan and tanh that take and return float or long double values. In a C program, tan and tanh always take and return double.


Required header

tan , tanf, tanl, tanh, tanhf, tanhl


For additional compatibility information, see Compatibility.

// crt_tan.c
// This program displays the tangent of pi / 4
// and the hyperbolic tangent of the result.

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

int main( void )
   double pi = 3.1415926535;
   double x, y;

   x = tan( pi / 4 );
   y = tanh( x );
   printf( "tan( %f ) = %f\n", pi/4, x );
   printf( "tanh( %f ) = %f\n", x, y );
tan( 0.785398 ) = 1.000000
tanh( 1.000000 ) = 0.761594
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.