Programming Language/C Language

[C] math.h 라이브러리

gapsoo 2023. 7. 16. 21:29

 

 


math.h는 여러 수학 함수들을 포함하는 C 언어 표준 라이브러리이다.

대부분의 함수들이 부동소수점을 다루며, 각도는 라디안을 사용한다.

 

 

 

 

출처 - 위키백과: https://ko.wikipedia.org/wiki/C_%EC%88%98%EC%8B%9D_%ED%95%A8%EC%88%98

 

C 수식 함수 - 위키백과, 우리 모두의 백과사전

위키백과, 우리 모두의 백과사전. C 수식 함수는 기초 수식 함수들을 구현하는 C 프로그래밍 언어의 표준 라이브러리 안의 함수들의 모임이다.[1][2] 함수 개요[편집] math.h는 여러 수학 함수들을

ko.wikipedia.org

 

 

 


C언어 공식 웹페이지 - Common mathematical functions: https://en.cppreference.com/w/c/numeric/math

 

Common mathematical functions - cppreference.com

[edit] Functions computes absolute value of an integral value (\(\small{|x|}\)|x|) (function) [edit] computes quotient and remainder of integer division (function) [edit] computes absolute value of an integral value (\(\small{|x|}\)|x|) (function) [edit] c

en.cppreference.com

 

 

 


 

math.h 라이브러리의 함수들은 다양한 수학 계산에 사용되며, 수치 계산, 삼각 함수 계산, 지수 및 로그 연산, 반올림 등에 유용하다. 이 라이브러리의 함수들을 사용하면 수학적인 계산을 쉽고 효율적으로 처리할 수 있다.

 

예를 들어, 다음과 같이 math.h 라이브러리의 함수를 사용하여 원주율 π를 계산할 수 있다:

 

1
2
3
4
5
6
7
8
#include <stdio.h>
#include <math.h>
 
int main() {
    double pi = M_PI;
    printf("원주율 π는 %.15f 입니다.\n", pi);
    return 0;
}
cs

 

위 예제에서 M_PI는 math.h 라이브러리에 미리 정의된 상수로서 원주율 값을 나타낸다.

출력 결과는 3.141592653589793과 같이 원주율의 근사값이 출력될 것이다.