函式
<cmath> <ctgmath>

sin

double sin(double x);
     double sin  (double x);      float sinf (float x);long double sinl (long double x);
     double sin (double x);      float sin (float x);long double sin (long double x);
     double sin (double x);      float sin (float x);long double sin (long double x);     double sin (T x);           // additional overloads for integral types
計算正弦
返回以弧度為單位的角度 x 的正弦值。

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

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

引數

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

返回值

x 弧度的正弦值。

示例

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

#define PI 3.14159265

int main ()
{
  double param, result;
  param = 30.0;
  result = sin (param*PI/180);
  printf ("The sine of %f degrees is %f.\n", param, result );
  return 0;
}

輸出

The sine of 30.000000 degrees is 0.500000.


另見