언어 자료구조 알고리즘/C11 표준 라이브러리 함수

COS, COSF, COSL

언제나휴일 2016. 1. 3. 16:13
반응형
double cos(double x); cosine 계산
float cosf(float x); cosine 계산
long double cosl(long double x); cosine 계산
 
입력 매개 변수 리스트
x radian
반환 값
cosine
 
사용 예
//C언어 표준 라이브러리 함수 사용법 가이드
//double cos(double x); cosine 계산
//float cosf(float x); cosine 계산
//long double cosl(long double x); cosine 계산
//0, 30, 45, 60, 90도의 cosine
 
#include <math.h>
#include <stdio.h>
 
int main(void)
{
    double radian;
    radian = 0.0;
    printf("%f \n", radian * 180 / 3.141592);
    printf("cos(%f)  = %.30f\n", radian, cos(radian));
    printf("cosf(%f) = %.30f\n", radian, cosf((float)radian));
    printf("cosl(%f) = %.30f\n", radian, cosl(radian));
 
    radian = 30 * 3.141592 / 180;
    printf("%f \n", radian * 180 / 3.141592);
    printf("cos(%f)  = %.30f\n", radian, cos(radian));
    printf("cosf(%f) = %.30f\n", radian, cosf((float)radian));
    printf("cosl(%f) = %.30f\n", radian, cosl(radian));
 
    radian = 45 * 3.141592 / 180;
    printf("%f \n", radian * 180 / 3.141592);
    printf("cos(%f)  = %.30f\n", radian, cos(radian));
    printf("cosf(%f) = %.30f\n", radian, cosf((float)radian));
    printf("cosl(%f) = %.30f\n", radian, cosl(radian));
 
    radian = 60 * 3.141592 / 180;
    printf("%f \n", radian * 180 / 3.141592);
    printf("cos(%f)  = %.30f\n", radian, cos(radian));
    printf("cosf(%f) = %.30f\n", radian, cosf((float)radian));
    printf("cosl(%f) = %.30f\n", radian, cosl(radian));
 
    radian = 90 * 3.141592 / 180;
    printf("%f \n", radian * 180 / 3.141592);
    printf("cos(%f)  = %.30f\n", radian, cos(radian));
    printf("cosf(%f) = %.30f\n", radian, cosf((float)radian));
    printf("cosl(%f) = %.30f\n", radian, cosl(radian));
 
    return 0;
}
}
 
출력
0.000000
cos(0.000000)  = 1.000000000000000000000000000000
cosf(0.000000) = 1.000000000000000000000000000000
cosl(0.000000) = 1.000000000000000000000000000000
30.000000
cos(0.523599)  = 0.866025458250249569047696240887
cosf(0.523599) = 0.866025447845458984375000000000
cosl(0.523599) = 0.866025458250249569047696240887
45.000000
cos(0.785398)  = 0.707106896725981814988415408152
cosf(0.785398) = 0.707106888294219970703125000000
cosl(0.785398) = 0.707106896725981814988415408152
60.000000
cos(1.047197)  = 0.500000188675109646929684004135
cosf(1.047197) = 0.500000178813934326171875000000
cosl(1.047197) = 0.500000188675109646929684004135
90.000000
cos(1.570796)  = 0.000000326794896538138350772186
cosf(1.570796) = 0.000000313916473260178463533521
cosl(1.570796) = 0.000000326794896538138350772186
반응형

'언어 자료구조 알고리즘 > C11 표준 라이브러리 함수' 카테고리의 다른 글

LOG, LOGF, LOGL  (0) 2016.01.03
LDEXP, LDEXPF, LDEXPL  (0) 2016.01.03
LOG1P, LOG1PF, LOG1PL  (0) 2016.01.03
TAN, TANF, TANL  (0) 2016.01.03
SIN, SINF, SINL  (0) 2016.01.03
ATAN2, ATAN2F, ATAN2L  (0) 2016.01.03
ATAN, ATANF, ATANL  (0) 2016.01.03
ASIN, ASINF, ASINL  (0) 2016.01.03
ACOS, ACOSF, ACOSL  (0) 2016.01.03
math.h  (0) 2016.01.03