|
|
Tor Olav Kristensen wrote:
>
> > >
> > > x^n = exp(n*ln(x))
> >
> > Uh, I think "x^n = pow(x, n)" is more likely...
>
> Yes, but do you know how this is actually computed ?
>
<remembering something>
<digging through harddisk>
\Delphi4\Source\Rtl\Sys\Math.pas:
function Power(Base, Exponent: Extended): Extended;
begin
if Exponent = 0.0 then
Result := 1.0 { n**0 = 1 }
else if (Base = 0.0) and (Exponent > 0.0) then
Result := 0.0 { 0**n = 0, n > 0 }
else if (Frac(Exponent) = 0.0) and (Abs(Exponent) <= MaxInt) then
Result := IntPower(Base, Integer(Trunc(Exponent)))
else
Result := Exp(Exponent * Ln(Base))
end;
Seems Tor is right, since i guess the C function pow(x,y) computes the
same (maybe apart from the optimization done here) this again answers the
questions about where it is defined.
Christoph
--
Christoph Hormann <chr### [at] gmxde>
IsoWood include, radiosity tutorial, TransSkin and other
things on: http://www.schunter.etc.tu-bs.de/~chris/
Post a reply to this message
|
|