tan, tanf, tanl

计算正切值。

语法

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

参数

x
角度(以弧度为单位)。

返回值

tan 函数返回 x 的正切值。 如果 x 大于等于 263,或小于等于 –263,则结果将失去意义。

输入 SEH 异常 _matherr 异常
± QNaN, IND _DOMAIN
± INF INVALID _DOMAIN

备注

由于 C++ 允许重载,因此你可以调用采用并返回 tanfloat 值的 long double 重载。 在 C 程序中,除非你使用 <tgmath.h> 宏来调用此函数,否则 tan 始终接受并返回 double

如果使用 <tgmath.h> 中的 tan 宏,自变量的类型将确定选择哪个版本的函数。 有关详细信息,请参阅泛型类型数学

默认情况下,此函数的全局状态范围限定为应用程序。 若要更改此行为,请参阅 CRT 中的全局状态

要求

例程 必需的标头 (C) 必需的标头 (C++)
tan, tanf, tanl <math.h> <cmath><math.h>
tan <tgmath.h>

有关兼容性的详细信息,请参阅 兼容性

示例

// 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

另请参阅

数学和浮点支持
acosacosfacosl
asinasinfasinl
atanatanfatanlatan2atan2fatan2l
coscosfcosl
sinsinfsinl
_CItan