tan, tanf, tanh, tanhf
TOC
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

tan, tanf, tanh, tanhf

Calculate the tangent (tan or tanf) or hyperbolic tangent (tanh or tanhf).

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

Parameters

x
Angle in radians.

Return Value

tan returns 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.

Input SEH Exception Matherr Exception
± QNAN,IND none _DOMAIN
± ∞
(tan, tanf)
INVALID _DOMAIN

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

Remarks

C++ allows overloading, so users can call overloads of tan and tanh that take float or long double types. In a C program, the tan and tanh functions always take and return double.

Requirements

Routine Required header Compatibility
tan, tanf, tanh, tanhf <math.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.

Libraries

All versions of the C run-time libraries.

Example

// 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 );
}

Output

tan( 0.785398 ) = 1.000000
tanh( 1.000000 ) = 0.761594

See Also

Floating-Point Support Routines | Long Double Routines | acos | asin | atan | cos | sin | Run-Time Routines and .NET Framework Equivalents

Show:
© 2016 Microsoft