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,050
  • 9
  • 29
  • 30

1 Answers1

38

They are, but you also need to #define _USE_MATH_DEFINES before you #include <cmath>

Alessandro Jacopson
  • 17,149
  • 14
  • 96
  • 148
davidi
  • 905
  • 2
  • 8
  • 13
  • 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