Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why define PI = 4*ATAN(1.d0)

What is the motivation for defining PI as

PI=4.D0*DATAN(1.D0) 

within Fortran 77 code? I understand how it works, but, what is the reasoning?

like image 966
ccook Avatar asked Jan 28 '10 21:01

ccook


People also ask

How do you define pi in Fortran?

fortran where most of the Fortran experts hang out. Their conclusion -- specify the constant by pi = 3.14159... (enough digits for required precision then some for safety).

How do you use double precision in Fortran?

A double-precision exponent consists of the letter D , followed by an optional plus or minus sign, followed by an integer. A double-precision exponent denotes a power of 10. The value of a double-precision constant is the product of that power of 10 and the constant that precedes the D .

How do you write Tan inverse in Fortran?

ATAN(X) computes the arctangent of X . The type shall be REAL or COMPLEX ; if Y is present, X shall be REAL.


1 Answers

This style ensures that the maximum precision available on ANY architecture is used when assigning a value to PI.

like image 196
John Gietzen Avatar answered Sep 17 '22 01:09

John Gietzen