函式
<cmath> <ctgmath>

tan

double tan (double x);
     double tan  (double x);      float tanf (float x);long double tanl (long double x);
     double tan (double x);      float tan (float x);long double tan (long double x);
     double tan (double x);      float tan (float x);long double tan (long double x);     double tan (T x);           // additional overloads for integral types
計算正切
返回角度 x(以弧度為單位)的正切值。

標頭檔案 <tgmath.h> 提供了此函式的型別通用宏版本。
此函式在 <complex><valarray> 中被過載(請參閱 complex tanvalarray tan)。
在此標頭檔案(<cmath>)中為 整型 提供了附加過載:這些過載在計算前有效地將 x 轉換為 double(對 T 為任何整型型別定義)。

此函式也在 <complex><valarray> 中被過載(請參閱 complex tanvalarray tan)。

引數

x
表示角度的值,以弧度為單位。
弧度等於 180/PI

返回值

x 弧度的正切值。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* tan example */
#include <stdio.h>      /* printf */
#include <math.h>       /* tan */

#define PI 3.14159265

int main ()
{
  double param, result;
  param = 45.0;
  result = tan ( param * PI / 180.0 );
  printf ("The tangent of %f degrees is %f.\n", param, result );
  return 0;
}

輸出

The tangent of 45.000000 degrees is 1.000000.


另見