First, cmath
defines M_PI
, use that.
Second, cpp macros do textual substitution. Which mean that this:
#define PI atan(1) * 4
a = 1 / PI;
will be turned into this:
a = 1 / atan(1) * 4;
before the c/c++ compiler gets a chance to see your code, and it will treat it equivalent to this:
a = (1 / atan(1)) * 4;
which is not what you want.
Your define should look like this:
#define PI (atan(1) * 4)
and everything should be fine.
This is not really strange behaviour, but well documented behaviour of the c-preprocessor.
You should search the web for other pitfalls with macros. (hint: parameter passing)