Re: Calculation assistance.. :)

From: Date: Fri, 19 Sep 2008 20:13:49 +0000
Subject: Re: Calculation assistance.. :)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-280551@lists.php.net to get a copy of this message
You originally had: $nPrincipal * ( $nMonthlyInterest / (1 - (1 + $nMonthlyInterest) ^ -$iMonths)) which, translate to in PHP $nPrincipal * ( $nMonthlyInterest / (1 - pow( ( 1 + $nMonthlyInterest ), -$iMonths ) ) ) On Sep 19, 2008, at 3:48 PM, Stephen Johnson wrote:
Right ... But that is producing even funkier results... doing pow( (1-(1+$nMonthlyInterest)) , ($iMonths*-1) ) ; Gives me : 4.2502451372964E-35 = 25000 * (0.0010416666666667 / 6.1270975733019E+35);
From: Eric Gorr <mailist@ericgorr.net> I believe what you are looking is: http://us2.php.net/manual/en/function.pow.php number pow ( number $base , number $exp ) Returns base raised to the power of exp On Sep 19, 2008, at 3:34 PM, Stephen Johnson wrote:
OK.. Math is NOT my forte ... I am converting a site from ASP to PHP ... And this calc is in the ASP Code : $nMonthlyInterest = $nRate / (12 * 100) //' Calculate monthly payment $nPayment = $nPrincipal * ( $nMonthlyInterest / (1 - (1 + $nMonthlyInterest) ^ -$iMonths)) Which then gives me in PHP 0.0010416666666667 = 1.25 / (12 * 100); -2.1701388888889 = 25000 * ( 0.0010416666666667 / (1 - (1 + 0.0010416666666667) ^ -12)) :: ^ is the problem ... The solution SHOULD be 2,097.47 ... Not –2.17 Would be willing to help correct this and make it valid in PHP?


« previous php.general (#280551) next »