tan, tanf, tanl

Calculates the tangent.

Syntax

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

Parameters

x
Angle in radians.

Return value

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.

Input SEH Exception Matherr Exception
± QNAN,IND none _DOMAIN
± INF INVALID _DOMAIN

Remarks

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

Requirements

Routine Required header (C) Required header (C++)
tan, tanf, tanl <math.h> <cmath> or <math.h>

For additional compatibility information, see Compatibility.

Example

// crt_tan.c
// This program displays the tangent of pi / 4
// Compile by using: cl crt_tan.c

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

int main( void )
{
   double pi = 3.1415926535;
   double x;

   x = tan( pi / 4 );
   printf( "tan( %f ) = %f\n", pi/4, x );
}
tan( 0.785398 ) = 1.000000

See also

Floating-Point Support
acos, acosf, acosl
asin, asinf, asinl
atan, atanf, atanl, atan2, atan2f, atan2l
cos, cosf, cosl
sin, sinf, sinl
_CItan