Greetings one and all,
I have a query about the preprocessor directive.
I am coding in C++ in the MS Visual Studio environment.
I was updating an old code recently where I had defined PI using the #define directive.
I decided to change this to
And the code ceased to work correctly. I think what is happening is that when I divide by PI it is dividing by 4.0 and multiplying atan(1.0).
I didn't think this was supposed to happen with #define.
What is the reason for this?
Does the compiler call PI or does it replace PI with 4.0*atan(1.0) when it is seen?
Is this a compiler dependent problem?
I have a query about the preprocessor directive.
I am coding in C++ in the MS Visual Studio environment.
I was updating an old code recently where I had defined PI using the #define directive.
Code:
#define PI 3.1415926535897932385
Code:
#define PI 4.0*atan(1.0)
I didn't think this was supposed to happen with #define.
What is the reason for this?
Does the compiler call PI or does it replace PI with 4.0*atan(1.0) when it is seen?
Is this a compiler dependent problem?
Comment