Usenet comp.unix.osf.misc (1992-2004)
 help / color / mirror / Atom feed
From: helbig@multivac.jb.man.ac.uk (Phillip Helbig)
Subject: Re: a**2 or a*a
Date: 1998/01/14	[thread overview]
Message-ID: <69iivp$47n$1@probity.mcc.ac.uk> (raw)
In-Reply-To: 34BCC4A4.F27A00D1@cranfield.ac.uk


In article <34BCC4A4.F27A00D1@cranfield.ac.uk>, Yon Han CHONG
<Y.H.Chong@cranfield.ac.uk> 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.




  parent reply	other threads:[~1998-01-14  5:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-14  5:00 a**2 or a*a Yon Han CHONG
1998-01-14  5:00 ` Peter Shenkin
1998-01-14  5:00 ` Phillip Helbig [this message]
1998-01-14  5:00 ` Arnaud Desitter
1998-01-15  5:00   ` Robert Corbett
1998-01-14  5:00 ` Kevin G. Rhoads
1998-01-14  5:00   ` Ed Overman
1998-01-15  5:00 ` Steve Lionel
1998-01-15  5:00 ` Nick Wagg
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox