sin()、sinf()、sinl() - 正弦の計算

標準

標準/拡張機能 C/C++ 依存項目

ISO C
POSIX.1
XPG4
XPG4.2
ISO/ANSI C++
C99
Single UNIX Specification、バージョン 3
C++ TR1 C99

両方  

形式

#include <math.h>

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);

機能説明

ラジアンで表された x で、x の正弦を 計算します。
注: これらの関数は、IEEE 2 進数浮動小数点形式と 16 進浮動小数点形式の両方で機能します。 IEEE 2 進数浮動小数点の詳細は、IEEE 2 進数浮動小数点を参照してください。

戻り値

正常に実行された場合、関数は、double、浮動、または long double の値として表された計算値を戻します。 正常に実行されなかった場合には、結果がアンダーフローであると、関数は 0 を戻し、errno を ERANGE に設定します。

XPG4.2 の特殊な動作: 以下のエラーが追加されます。
エラー・コード
説明
EDOM
引数が関数の内部制限 (約 250) を超えました。

CELEBS27
⁄* CELEBS27                                      

   This example computes y as the sine of &pi.&slr.2.                           
                                                                                
 *⁄                                                                             
#include <math.h>                                                               
#include <stdio.h>                                                              
                                                                                
int main(void)                                                                  
{                                                                               
   double pi, x, y;                                                             
                                                                                
   pi = 3.1415926535;                                                           
   x = pi⁄2;                                                                    
   y = sin(x);                                                                  
                                                                                
   printf("sin( %lf ) = %lf¥n", x, y);                                          
}                                                                               
出力:
sin( 1.570796 ) = 1.000000

関連情報