Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!strath-cs!ex-dcs!exua!CDHWilli From: CDHWilli@exua.exeter.ac.uk (Charles Williams) Newsgroups: comp.lang.fortran Subject: Re: Fortran 90 status Message-ID: Date: 18 May 91 23:02:07 GMT References: <13372@exodus.Eng.Sun.COM> <23881@lanl.gov> <1991May16.195328.727@casbah.acns.nwu.edu> Sender: CDHWilli@exua.exeter.ac.uk Distribution: comp Organization: Computer Unit. - University of Exeter. UK Lines: 39 In-reply-to: ravi@earth.ce.nwu.edu's message of 16 May 91 19:53:28 GMT >ravi@earth.ce.nwu.edu (Ravi Sinha) <1991May16.195328.727@casbah.acns.nwu.edu> > >Real DO control variables allow you to have loops like: > DO r = 1,100000,0.1 > ... > ENDDO > >The replacement with integer DO control variable would be: > rbegin = 1 > rint = 0.1 > DO i=1,1000000 > r = rbegin + (i-1)*rint > ... > ENDDO > >Maybe someone can tell me why the second form is better from an >optimization point of view, and why the first form should be disallowed. You've picked an interesting example because machines use binary/hex representations of real numbers and have no exact real representation for the number 0.1 This means that the number of times an optimised loop of this type is executed is not always the same as the unoptimised version, especially if you are using the facilities of ieee arithmetic to adjust the FPU behaviour at run time... Some F77 compilers squeal if you even try to compare two reals for equality or inequality. IMHO even if the precise behaviour of reals *is* defined somewhere it's easier to use integer for do-looping and avoid having to wonder about the portability/optimisation/ieee settings/termination issues that the reals involve...er, flame-suit on... My news reader wants more lines here