Path: utzoo!attcan!uunet!wyse!vsi1!ubvax!ames!nrl-cmf!ukma!tut.cis.ohio-state.edu!mailrus!cornell!rochester!ritcv!ritcsh!gregory
From: gregory@ritcsh.UUCP (Gregory Conway)
Newsgroups: comp.lang.c
Subject: Re: Exponentiation in C (was: How not to write a loop)
Message-ID: <3167@ritcsh.UUCP>
Date: 30 Jun 88 22:29:41 GMT
References: <16276@brl-adm.ARPA> <329@accelerator.eng.ohio-state.edu> <4778@haddock.ISC.COM>
Organization: Computer Science House @ RIT, Rochester, NY
Lines: 36

In article <4778@haddock.ISC.COM>, karl@haddock.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.
] 
] >Apparently Bill missed the discussion a few months ago about exponentiation
] >in C.  There was considerable disagreement about what should be done about
] >the problem, and a rather large number of correspondents seemed unable to
] >consider computing powers except by the pow(x,y) function, which does not
] >use the reasonably quick and exact method.


I'm still a little wet behind the ears where C is concerned, so (politely)
correct me if I'm wrong, but what's wrong with this:


		y = 3.0^2
		log (y) = log (3.0^2)
		log (y) = 2 * log(3.0)

		So......

		y = exp ((double)2 * log(3.0));

Mathematically, it should work.  I'm just not so sure that it will compile.
How about it??

 
-- 
   ==>  Gregory Conway @ Computer Science House, RIT, Rochester, New York  <==
"I never did write that love song, the words just never seemed to flow.
 Now sad in reflection, did I gaze through perfection, 
 and examine the shadows on the other side of morning."  - Marillion