cos : cosine 값 연산 sin : sine 값 연산 tan : tangent 값 연산 acos : arc cosine 값 연산 asin : arc sine 값 연산 atan : arc tangent 값 연산 atan2 : 매개변수가 2개인 arc tangent 값 연산
2) 지수, 로그 함수
exp : 지수 연산 log : 자연로그 연산 log10 : 상용로그 연산
3) 제곱함수
pow : 거듭제곱 연산 sqrt : 거듭제곱근 연산
4) 반올림함수
ceil : 올림연산 round : 반올림 연산 floor : 내림연산
5) 최대값∙최소값 함수
fmax : 매개변수 중 최대값 반환 fmin : 매개변수 중 최소값 반환
6) 절대값 함수
abs : 정수의 절대값 연산 fabs : 실수의 절대값 연산
# 라이브러리 함수 활용
1. 삼각함수
#include
#include
#define PI 3.14159265
int main ()
{
double param, result;
float paramf,resultf;
param = 30.0;
result = sin (param * PI/180);
printf ("The sine of %f degrees is %f.\n", param, result );
param = 60.0;
result = cos ( param * PI / 180 );
printf ("The cosine of %f degrees is %f.\n", param, result );
paramf = 30.0;
resultf = sinf (paramf*PI/180);
printf ("The sine of %f degrees is %f.\n", paramf, resultf );
return 0;
}
2. 지수 로그함수
#include
#include
int main ()
{
double param, result;
param = 5.0;
result = exp (param);
printf ("The exponential value of %f is %f.\n", param, result );
param = 1000.0;
result = log10 (param);
printf ("log10(%f) = %f\n", param, result );
param = 5.5;
result = log (param);
printf ("log(%f) = %f\n", param, result );
return 0;
}
#include
#include
intmain ()
{
printf( "ceil of 2.3 is %.1f\n", ceil(2.3) );
printf( "ceil of 3.8 is %.1f\n", ceil(3.8) );
printf( "ceil of -2.3 is %.1f\n", ceil(-2.3) );
printf( "ceil of -3.8 is %.1f\n", ceil(-3.8) );
return 0;
}
// 결과값
ceil of 2.3 is 3.0
ceil of 3.8 is 4.0
ceil of -2.3 is -2.0
ceil of -3.8 is -3.0
#include
#include
int main ()
{
printf ( “floor of 2.3 is %.1f\n", floor(2.3) );
printf ( "floor of 3.8 is %.1f\n", floor(3.8) );
printf ( "floor of -2.3 is %.1f\n", floor(-2.3) );
printf ( "floor of -3.8 is %.1f\n", floor(-3.8) );
return 0;
}
// 결과값
floor of 2.3 is 2.0
floor of 3.8 is 3.0
floor of -2.3 is -3.0
floor of -3.8 is -4.0
#include
#include
int main ()
{
printf ( “round of 2.3 is %.1f\n", round(2.3) );
printf ( "round of 3.8 is %.1f\n", round(3.8) );
printf ( "round of -2.3 is %.1f\n", round(-2.3) );
printf ( "round of -3.8 is %.1f\n", round(-3.8) );
return 0;
}
//결과값
floor of 2.3 is 2.0
floor of 3.8 is 3.0
floor of -2.3 is -3.0
floor of -3.8 is -4.0