From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc89c,f8f184f3bc3517df X-Google-Attributes: gidfc89c,public X-Google-Thread: 1094ba,f8f184f3bc3517df X-Google-Attributes: gid1094ba,public X-Google-Thread: f678f,f8f184f3bc3517df X-Google-Attributes: gidf678f,public From: helbig@multivac.jb.man.ac.uk (Phillip Helbig) Subject: Re: a**2 or a*a Date: 1998/01/14 Message-ID: <69iivp$47n$1@probity.mcc.ac.uk>#1/1 X-Deja-AN: 315864062 References: <34BCC4A4.F27A00D1@cranfield.ac.uk> Reply-To: helbig@man.ac.uk Organization: University of Manchester, NRAL Newsgroups: comp.lang.fortran,comp.unix.osf.misc,comp.unix.programmer In article <34BCC4A4.F27A00D1@cranfield.ac.uk>, Yon Han CHONG writes: > Is there speed difference between a**2 and a*a. There used to be, but any good compiler should do this sort of `optimisation' for you. In fact, I think it is probably better not to do any optimisation `by hand' since compilers these days should be smart enough to do it for you. The advantage of letting the compiler do it for you is that it will do what is best FOR IT, whereas if you rely on optimisation by hand, what is best might be different for different compilers. If you do the opposite of this sort of thing, writing more or less FORmula TRANslation, then the code will be easier to maintain since it is more obvious what you are doing, and why. And probably it will also be obvious to the compiler what you are doing, as well, which will let it make the best of it. > I am using DEC fortran 90. You'll probably get a response from Steve Lionel as well, but my guess is that DEC Fortran 90 will catch this at compile time and the compiled code will be the same in both cases (unless perhaps you have turned off all optimisation). Note that DEC Fortran 90 (and most? all? of their compilers) have a sensible optimisation by default, and if I recall correctly, don't ever do `dangerous' optimisation. -- Phillip Helbig Email .......... p.helbig@jb.man.ac.uk Nuffield Radio Astronomy Laboratories Tel. ..... +44 1477 571 321 (ext. 297) Jodrell Bank Fax ................. +44 1477 571 618 Macclesfield Telex ................. 36149 JODREL G UK-Cheshire SK11 9DL Web .... http://www.jb.man.ac.uk/~pjh/ My opinions are not necessarily those of NRAL or the University of Manchester.