Print

Print


Hi Fortraners:

Its been awhile since I took Fortran 101 and the standard has been revised a few times, and now I'm stuck on questions of precision:

Just what does the standard have to say about mixing variables of different KINDS and and can you get into trouble by doing so?

For example, mixing integers and double as in

A=B/(1+C)

implicitly converts the integer "1" into a real, but is it a single "real" or a double real? (A, B and C are declared double).

Also, what is the default definition for "E" vs "D" specifications.  Will 0.1D-1 give the same result on a 64 bit processor as on a 32 bit processor (I know, the standard says nothing about processor, but somewhere it must define "D" vs "E").

I made up a small program (attached) to test some possibilities, and got some answers that don't make too much sense, including, 

- why does C4 appear to have full precision when it's denominator is "single"

- are integer constants (e.g. 1.0) implicitly converted differently than non-integer constants (e.g. 1.5)

- can you lose precision when dividing by a real single precision constant that may be converted to a multiplication (e.g.  A/3. -> a*.333... at compilation time) or 
must it always be written A/3._double to be sure.

- how does one properly set a  parameter using "D" or "E" notation (ERR2 vs ERR3) in the example.

Thanks for any light anyone can shed on these matters.

Mike Milgram