共用方式為


sin、sinf、sinl、sinh、sinhf、sinhl

計算正弦函數和雙曲線正弦函數。

double sin(
   double x 
);
float sin(
   float x
);  // C++ only
long double sin(
   long double x
);  // C++ only
float sinf(
   float x 
);
long double sinl(
   long double x
);
double sinh(
   double x 
);
float sinh(
   float x 
);  // C++ only
long double sinh(
   long double x
);  // C++ only
float sinhf(
   float x
);
long double sinhl(
   long double x
);

參數

  • x
    角度 (以弧度為單位)。

傳回值

sin 函式傳回 x 的正弦函數。 如果 x 大於或等於 263 ,或者小於或等於 – 263 ,會造成喪失意義的結果。

sinh 函式傳回 x 的雙曲線正弦函數。 根據預設,若結果太大,sinh 會將ERANGE 設為 errno 並傳回 ± HUGE_VAL。

輸入

SEH 例外狀況

Matherr 例外狀況

± QNAN,IND

None

_DOMAIN

± ∞ (sin、sinf、sinl)

INVALID

_DOMAIN

|x| ≥ 7.104760e+002 (sinh, sinhf, sinhl)

OVERFLOW+INEXACT

OVERFLOW

如需傳回碼的詳細資訊,請參閱errno、_doserrno、_sys_errlist 和 _sys_nerr

備註

因為 C++ 允許多載,您可以呼叫會接受並傳回 float 或 long double 值的 sin 和 sinh 之多載。 在 C 程式,sin 和 sinh 一律接受並傳回 double。

需求

常式

必要的標頭

sin, sinf, sinl, sinh, sinhf, sinhl

<math.h>

如需其他相容性資訊,請參閱 相容性

範例

// crt_sincos.c
// This program displays the sine, hyperbolic
// sine, cosine, and hyperbolic cosine of pi / 2.
//

#include <math.h>
#include <stdio.h>

int main( void )
{
   double pi = 3.1415926535;
   double x, y;

   x = pi / 2;
   y = sin( x );
   printf( "sin( %f ) = %f\n", x, y );
   y = sinh( x );
   printf( "sinh( %f ) = %f\n",x, y );
   y = cos( x );
   printf( "cos( %f ) = %f\n", x, y );
   y = cosh( x );
   printf( "cosh( %f ) = %f\n",x, y );
}
  

.NET Framework 對等用法

請參閱

參考

浮點支援

acos、acosf、acosl

asin、asinf、asinl

atan、atanf、atanl、atan2、atan2f、atan2l

cos、cosf、cosl、cosh、coshf、coshl

tan、tanf、tanl、tanh、tanhf、tanhl

_CIsin