I want to use the math constants, such as M_PI and M_E, in Visual C++ 2008. I assumed they were defined in the cmath header.
Asked
Active
Viewed 1.7k times
1 Answers
38
They are, but you also need to #define _USE_MATH_DEFINES
before you #include <cmath>

Alessandro Jacopson
- 18,047
- 15
- 98
- 153

davidi
- 905
- 2
- 8
- 14
-
1Note that other includes can implicitly do including `
`, so prefer to place `#define _USE_MATH_DEFINES` before any header includes. Place define into `stdafx.h` if you use precompiled headers. – Sergey Shambir Oct 13 '16 at 06:10