On 15 May 96 Dan Ugrin said to Justin Marquez...
DU> Number**Power in Fortran translates to Exp(Ln(Number)*Power) in Pascal.
It might be better to put that expression within a function that can detect
and handle the pathological cases. For example, -3.5 raised to the power 3
exists, but the above expression will crash trying to find the Ln of a
negative number.
The following untested prototype is based on my memories of high-school
math, check it out before you use it (I'm not sure if 0**0 is 0 or 1) ...
If Power = 0.0 then result = 1.0 { anything to power 0 is one ? }
else if Number = 0.0 then result = 0.0
else if Number > 0.0 then result := Exp(Ln(Number)*Power)
else if (Frac(Power) = 0.0) then { Power is Integer }
begin
result := 1.0 ;
for j := 1 to Trunc(Abs(Power)) do result := result * Number ;
if Power < 0.0 then result := 1.0/result ;
end
else { report failure } ;
--- PPoint 2.00
---------------
* Origin: Kingston, Canada (1:249/109.11)
|