Re: #define and external static

From: Fan Zhang (fanzhang_at_sas.upenn.edu)
Date: 10/13/04


Date: Wed, 13 Oct 2004 11:09:07 -0400

Thanks for everybody's input.

This is what I found out last night after playing with it at home.

It is not a good way to write
#define radian 180./PI, although it is legal in my compiler (DevC++). The
problem with it is #define does not do the calculation, it just does the
REPLACEMENT! That is to say, when I tried to calculate 1./radian, it did
1./180./PI instead of 1./(180./PI). That is why the result did not make
sense in my program, at least it appears to be. :-)

Thanks again!

"Fan Zhang" <fanzhang@sas.upenn.edu> wrote in message
news:ckhl6c$fgj4$1@netnews.upenn.edu...
> Hi group,
>
> This is a follow-up of the question I posted this afternoon.
>
> I tried to define two constants, PI and radian in that program in the
> following way,
> #define PI 3.1415926
> #define radian 180./PI
>
> I wonder whether they are the same as
> static double PI=3.1415926;
> static double radian=180./PI;
>
> If they are not, why?
>
> Thanks!
>
> Regards,
> Fan
>
>