Usenet comp.unix.osf.misc (1992-2004)
 help / color / mirror / Atom feed
From: corbett@lupa.eng.sun.com (Robert Corbett)
Subject: Re: a**2 or a*a
Date: 1998/01/15	[thread overview]
Message-ID: <69jotq$pv5@engnews1.Eng.Sun.COM> (raw)
In-Reply-To: 34BCD934.41C6@bristol.ac.uk


In article <34BCD934.41C6@bristol.ac.uk>,
Arnaud Desitter  <Arnaud.Desitter@bristol.ac.uk> wrote:
>Yon Han CHONG wrote:
>> 
>> Is there speed difference between a**2 and a*a.
>> 
>No. A good compiler (and the digital's one is good in this respect) will
>use the best algorithm for a**b, i.e. a multiplication if b=2.
>
>Cheers,
>Arnaud

While it is true that the best implementation of a**2 is a*a on most
machines, there is no "best" algorithm for most of the remaining powers.
Implementing a**3 as a*a*a causes the expression to have a 1 ulp error
bound.  Implementing it as pow(a, 3.0) will cause it to have an error
bound of just over 1/2 ulp, assuming a good implementation of pow.

The other integer powers that have obvious implementations are -1 and 1.
The power zero has an obvious implementation that drives people who
think we are doing math instead of computing nuts.

					Sincerely,
					Bob Corbett



  reply	other threads:[~1998-01-15  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
1998-01-14  5:00 ` Arnaud Desitter
1998-01-15  5:00   ` Robert Corbett [this message]
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