タンジェントを計算します。
構文
double tan( double x );
float tanf( float x );
long double tanl( long double x );
#define tan(x) // Requires C11 or later
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++ ではオーバーロードが可能であるため、tan または float の値を受け取って返す long double のオーバーロードを呼び出すことができます。 C プログラムでは、この関数を呼び出すために <tgmath.h> マクロが使用されていない限り、tan は常に double を受け取って返します。
<tgmath.h>のtanマクロを使用する場合、引数の型によって、選択される関数のバージョンが決まります。 詳細については、「ジェネリック型数値演算」を参照してください。
既定では、この関数のグローバル状態の適用対象は、アプリケーションになります。 この動作を変更するには、「CRT でのグローバル状態」を参照してください。
要件
| ルーチンによって返される値 | 必須ヘッダー (C) | 必須ヘッダー (C++) |
|---|---|---|
tan、 tanf、 tanl |
<math.h> |
<cmath> または <math.h> |
tan マクロ |
<tgmath.h> |
互換性の詳細については、「 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>
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
関連項目
数値演算と浮動小数点のサポート
acos、 acosf、 acosl
asin、 asinf、 asinl
atan、 atanf、 atanl、 atan2、 atan2f、 atan2l
cos、 cosf、 cosl
sin、 sinf、 sinl
_CItan