sin, sinf, sinl 함수

double sin(double x); sine 계산

float sinf(float x); sine 계산

long double sinl(long double x); sine 계산

입력 매개 변수 리스트

x radian

반환 값

sine 값

사용 예

//C언어 표준 라이브러리 함수 가이드
//double sin(double x); sine 계산
//float sinf(float x); sine 계산
//long double sinl(long double x); sine 계산
//0, 30, 45, 60, 90도의 sine 값

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

int main(void)
{
    double radian;
    radian = 0.0;
    printf("%f 도\n", radian * 180 / 3.141592);
    printf("sin(%f)  = %.30f\n", radian, sin(radian));
    printf("sinf(%f) = %.30f\n", radian, sinf((float)radian));
    printf("sinl(%f) = %.30f\n", radian, sinl(radian));

    radian = 30 * 3.141592 / 180;
    printf("%f 도\n", radian * 180 / 3.141592);
    printf("sin(%f)  = %.30f\n", radian, sin(radian));
    printf("sinf(%f) = %.30f\n", radian, sinf((float)radian));
    printf("sinl(%f) = %.30f\n", radian, sinl(radian));

    radian = 45 * 3.141592 / 180;
    printf("%f 도\n", radian * 180 / 3.141592);
    printf("sin(%f)  = %.30f\n", radian, sin(radian));
    printf("sinf(%f) = %.30f\n", radian, sinf((float)radian));
    printf("sinl(%f) = %.30f\n", radian, sinl(radian));

    radian = 60 * 3.141592 / 180;
    printf("%f 도\n", radian * 180 / 3.141592);
    printf("sin(%f)  = %.30f\n", radian, sin(radian));
    printf("sinf(%f) = %.30f\n", radian, sinf((float)radian));
    printf("sinl(%f) = %.30f\n", radian, sinl(radian));

    radian = 90 * 3.141592 / 180;
    printf("%f 도\n", radian * 180 / 3.141592);
    printf("sin(%f)  = %.30f\n", radian, sin(radian));
    printf("sinf(%f) = %.30f\n", radian, sinf((float)radian));
    printf("sinl(%f) = %.30f\n", radian, sinl(radian));

    return 0;
}

출력

0.000000 도
sin(0.000000)  = 0.000000000000000000000000000000
sinf(0.000000) = 0.000000000000000000000000000000
sinl(0.000000) = 0.000000000000000000000000000000
30.000000 도
sin(0.523599)  = 0.499999905662436239239809765422
sinf(0.523599) = 0.499999910593032836914062500000
sinl(0.523599) = 0.499999905662436239239809765422
45.000000 도
sin(0.785398)  = 0.707106665647094345672485360410
sinf(0.785398) = 0.707106649875640869140625000000
sinl(0.785398) = 0.707106665647094345672485360410
60.000000 도
sin(1.047197)  = 0.866025294852785898491731586546
sinf(1.047197) = 0.866025328636169433593750000000
sinl(1.047197) = 0.866025294852785898491731586546
90.000000 도
sin(1.570796)  = 0.999999999999946598272515529970
sinf(1.570796) = 1.000000000000000000000000000000
sinl(1.570796) = 0.999999999999946598272515529970