Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!udel!rochester!kodak!uupsi!sunic!news.funet.fi!fuug!funic!nntp.hut.fi!nntp!jkorpela From: jkorpela@vipunen.hut.fi (Jukka Korpela) Newsgroups: comp.lang.fortran Subject: Re: Fortran 90 status Message-ID: Date: 17 May 91 09:14:28 GMT References: <13372@exodus.Eng.Sun.COM> <23881@lanl.gov> <1991May16.195328.727@casbah.acns.nwu.edu> Sender: usenet@nntp.hut.fi (Usenet pseudouser id) Distribution: comp Organization: Helsinki University of Technology, Finland Lines: 22 In-Reply-To: ravi@earth.ce.nwu.edu's message of 16 May 91 19:53:28 GMT Nntp-Posting-Host: vipunen.hut.fi You stated that Real DO control variables allow you to have loops like: DO r = 1,100000,0.1 ... ENDDO and asked why it should be disallowed and why a DO loop which uses an integer control variable is better from an optimization point of view. I think (I hope!) the reason for disallowing it (or calling it obsolescent) is not optimization, although it seems intuitively clear that it is usually easier to optimize a loop with an integer control variable. The point is that using a real control variable leads to INACCURACIES. A value such as 0.1 is not reprented exactly on most computers. The inaccuracy is small but it is ACCUMULATED. Thus the values for which the loop is actually executed differ from what you probably expect. Moreover, the number of executions is very often off-by-one; if you have DO r=1,100000,0.1, the last value of r for which the loop is executed might be about 99999.9, since after adding 0.1 to it the result might be more than 100000 due to inaccuracies.