23

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.

batty
  • 7,528
  • 9
  • 31
  • 30

1 Answers1

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
  • 1
    Note 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