본문 바로가기
컴퓨터/C

C 언어 math 정의 상수

by Begi 2020. 10. 22.
반응형

C언어의 math.h에는 다음과 같은 상수들이 정의되어 있다. 하지만 C 표준에는 없기 때문에 컴파일러에 따라 정의되어 있지 않기도 하다.

 

M_E : The base of natural logarithms.

M_LOG2E : The logarithm to base 2 of M_E.

M_LOG10E : The logarithm to base 10 of M_E.

M_LN2 : The natural logarithm of 2.

M_LN10 : The natural logarithm of 10.

M_PI : Pi, the ratio of a circle’s circumference to its diameter.

M_PI_2 : Pi divided by two.

M_PI_4 : Pi divided by four.

M_1_PI : The reciprocal of pi (1/pi)

M_2_PI : Two times the reciprocal of pi.

M_2_SQRTPI : Two times the reciprocal of the square root of pi.

M_SQRT2 : The square root of two.

M_SQRT1_2 : The reciprocal of the square root of two (also the square root of 1/2).

 

원주율 파이는 M_PI로 다음과 같이 정의되어 있다.

#define M_PI   3.14159265358979323846264338327950288

 

반응형

'컴퓨터 > C' 카테고리의 다른 글

C의 ABS 매크로 함수  (0) 2020.11.01
구조체 비트 필드  (0) 2020.10.28
C 나머지 연산  (0) 2020.10.21
C struct 구조체 사용하기  (0) 2020.10.21
C 구조체를 함수 리턴으로 사용하기  (0) 2020.10.16

댓글