Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!claris!apple!bgibbons
From: bgibbons@Apple.COM (Bill Gibbons)
Newsgroups: comp.lang.c
Subject: Re: Exponentiation in C (was: How not to write a loop)
Message-ID: <12971@apple.Apple.COM>
Date: 28 Jun 88 17:37:12 GMT
References: <16276@brl-adm.ARPA> <329@accelerator.eng.ohio-state.edu> <12784@apple.Apple.COM> <808@l.cc.purdue.edu> <4778@haddock.ISC.COM>
Reply-To: bgibbons@apple.apple.com.UUCP (Bill Gibbons)
Organization: Apple Computer Inc, Cupertino, CA
Lines: 15

In article <4778@haddock.ISC.COM> karl@haddock.ima.isc.com (Karl Heuer) writes:
>In article <808@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes:
>>In article <12784@apple.Apple.COM>, bgibbons@Apple.COM (Bill Gibbons) writes:
>>>... raising a floating-point value to an integer (typed as integer) power is
>>>always done with repeated multiplies (in about log2(exponent) time),
>That's a strange comment to be posting to a C newsgroup.

Actually, I meant this from an algorithmic point of view: if the implementor
knows that the exponent is an integer (without checking, e.g. it was typed
that way) the library code should use repeated multiplies.  This is trivial to
do in C++ by overloading pow().  In C, you have to name the library routine
something else, of course.  Or, as has been noted, change the language.

Bill Gibbons
bgibbons@apple.apple.com (contractor)