title | description | ms.date | api_name | api_location | api_type | topic_type | f1_keywords | helpviewer_keywords | ms.assetid | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tan, tanf, tanl | API reference for tan, tanf, and tanl; which calculate the tangent of a floating-point value. | 1/15/2021 |
|
|
|
|
|
| 36cc0ce8-9c80-4653-b354-ddb3b378b6bd |
Calculates the tangent.
doubletan( doublex ); floattanf( floatx ); long doubletanl( long doublex ); #definetan(x) // Requires C11 or higher
floattan( float x ); // C++ onlylongdoubletan( longdouble x ); // C++ only
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.
Input | SEH exception | _matherr exception |
---|---|---|
± QNaN, IND | none | _DOMAIN |
± INF | INVALID | _DOMAIN |
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.
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.
// crt_tan.c// This program displays the tangent of pi / 4// Compile by using: cl crt_tan.c#include<math.h>#include<stdio.h>intmain( void ) { doublepi=3.1415926535; doublex; x=tan( pi / 4 ); printf( "tan( %f ) = %f\n", pi/4, x ); }
tan( 0.785398 ) = 1.000000
Math and floating-point supportacos
, acosf
, acosl
asin
, asinf
, asinl
atan
, atanf
, atanl
, atan2
, atan2f
, atan2l
cos
, cosf
, cosl
sin
, sinf
, sinl
_CItan