Muokkaa

Jaa


tan, tanf, tanl

Calculates the tangent.

Syntax

double tan( double x );
float tanf( float x );
long double tanl( long double x );
#define tan(x) // Requires C11 or higher
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, unless you're using the <tgmath.h> macro to call this function, tan always takes and returns double.

If you use the tan macro from <tgmath.h>, the type of the argument determines which version of the function is selected. See Type-generic math for details.

By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.

Requirements

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

For more 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

Math and floating-point support
acos, acosf, acosl
asin, asinf, asinl
atan, atanf, atanl, atan2, atan2f, atan2l
cos, cosf, cosl
sin, sinf, sinl
_CItan