I have just recently upgraded to PHP 4.2.2 and am trying to get this 
version to do the following compounding interest problem, which PHP3 had 
no problem with.

$futureValue = $currentAmount * pow( 1 + ($interestRatePercent/100), 
$timeInYears);

In PHP4, it issues a warning saying " Invalid argument(s) passed to 
pow() in C:\Server\Apache Group\Apache2\htdocs\Compound 
Interest\cinterest.php3 on line 24".  In reading about the pow() 
function, it appears that in PHP 4 the pow function use to return floats 
whereas now it returns integers.  So my first instinct was to try to 
cast what power returns into a float.  So I tried various tests (since I 
haven't cast in PHP before).  I tried everything from:

(float) $futureValue = $currentAmount * pow( 1 + 
($interestRatePercent/100), $timeInYears);

to:

$temp = 1 + ($interestRatePercent/100);
echo "<br>$temp to the $timeInYears<br>";  //i.e echos 1.06 to the 2    
(float) $temp1 = (float) pow($temp, $timeInYears);
$futureValue = $currentAmount * $temp1;

I am still getting the warning about invalid arguments passed to pow(). 
  So what is the deal here, how am I suppose to do this type of math 
problem?

Thanks for any help or ideas.
        -Andrew V. Romero


-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to