컴퓨터/C

C 언어 math 정의 상수

Begi 2020. 10. 22. 23:28
반응형

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

 

반응형