When using the following to compute PI in fortran77, will the compiler evaluate this value or will it be evaluated at run time?
PI=4.D0*DATAN(1.D0)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
EDIT: depends on the compiler: see my EDIT below. EDIT END
i second Mick Sharpe’s suggestion that it will be evaluated at runtime. just out of curiosity, i compiled
PI=4.D0*DATAN(1.D0)with Silverfrost’s ftn77 compiler and looked at the generated binary. the relevant part looks like so:so indeed, no compiler cleverness here.
this of course might be different with another compiler (eg. g77). EDIT: apparently, with g77 (the fortran77 front-end for gcc) it is possible (and enabled by default) to use gcc’s built-in atan function to auto-fold
PI=4.D0*DATAN(1.D0)into a constant. EDIT END