The sin functions - sin, sinf, sinl

正弦 (sin) を計算します.

sin

#include <math.h>
double sin(
    double x
);

sin 関数は x の正弦 (sin) を計算し,結果を double 型で返します.

sinf (C99)

#include <math.h>
float sinf(
    float x
);

sinf 関数は x の正弦 (sin) を計算し,結果を float 型で返します.

sinl (C99)

#include <math.h>
long double sinl(
    long double x
);

sinl 関数は x の正弦 (sin) を計算し,結果を long double 型で返します.

戻り値

  • 正弦値

数学上の表記

sin

C言語サンプルプログラム

以下にsin,sinf,sinl 関数それぞれを使用したサンプルプログラムを示します.

/* header files */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

/* macros */
#define PI 3.14159265

/* main */
int main(void) {
    double d_angle = PI / 6.0, d_result;
    float f_angle = PI / 3.0, f_result;
    long double ld_angle = PI / 2.0L, ld_result;

    d_result = sin(d_angle);
    f_result = sinf(f_angle);
    ld_result = sinl(ld_angle);

    printf("sin(pi / 6): %.8f\n", d_result);
    printf("sinf(pi / 3): %.8f\n", f_result);
    printf("sinl(pi / 2): %.8Lf\n", ld_result);

    return EXIT_SUCCESS;
}

実行例

サンプルプログラムの実行結果は以下のようになります.

sin(pi / 6): 0.50000000
sinf(pi / 3): 0.86602545
sinl(pi / 2): 1.00000000