tan、tanf、tanl、tanh、tanhf、tanhl
計算正切 (tan、 tanf或 tanl),或者 雙曲線正切 (tanh、 tanhf或 tanhl)。
double tan(
double x
);
float tan(
float x
); // C++ only
long double tan(
long double x
); // C++ only
float tanf(
float x
);
long double tanl(
long double x
);
double tanh(
double x
);
float tanh(
float x
); // C++ only
long double tanh(
long double x
); // C++ only
float tanhf(
float x
);
long double tanhl(
long double x
);
參數
- x
角度 (以弧度為單位)。
傳回值
tan 函式傳回 x的正切函數。 如果 x 大於或等於 263 或小於或等於 – 263 ,則會在結果上傳回顯著性位元遺失發生。
tanh 函式傳回 x的雙曲線正切函數。 不會回傳錯誤。
輸入 |
SEH 例外狀況 |
Matherr 例外狀況 |
---|---|---|
± QNAN,IND |
無 |
_DOMAIN |
± ∞ (tan, tanf) |
INVALID |
_DOMAIN |
備註
因為 C++ 允許多載,您可以呼叫會接受並傳回 float 或 long double 值的 tan 和 tanh 多載。 在 C 程式,tan 和 tanh 一律接受並傳回 double。
需求
常式 |
必要的標頭 |
---|---|
tan, tanf, tanl, tanh, tanhf, tanhl |
<math.h> |
如需其他相容性資訊,請參閱 相容性。
範例
// crt_tan.c
// This program displays the tangent of pi / 4
// and the hyperbolic tangent of the result.
//
#include <math.h>
#include <stdio.h>
int main( void )
{
double pi = 3.1415926535;
double x, y;
x = tan( pi / 4 );
y = tanh( x );
printf( "tan( %f ) = %f\n", pi/4, x );
printf( "tanh( %f ) = %f\n", x, y );
}
.NET Framework 對等用法
請參閱
參考
atan、atanf、atanl、atan2、atan2f、atan2l
cos、cosf、cosl、cosh、coshf、coshl